@graphql-tools/merge
Advanced tools
Comparing version 9.0.0-rc-20230519104353-b09f3180 to 9.0.0-rc-20230519104627-f6fea064
@@ -54,3 +54,3 @@ "use strict"; | ||
const result = (0, utils_1.mergeDeep)(resolvers, true); | ||
if (options === null || options === void 0 ? void 0 : options.exclusions) { | ||
if (options?.exclusions) { | ||
for (const exclusion of options.exclusions) { | ||
@@ -57,0 +57,0 @@ const [typeName, fieldName] = exclusion.split('.'); |
@@ -19,3 +19,3 @@ "use strict"; | ||
} | ||
else if (!(config === null || config === void 0 ? void 0 : config.reverseArguments)) { | ||
else if (!config?.reverseArguments) { | ||
acc[dupIndex] = current; | ||
@@ -22,0 +22,0 @@ } |
@@ -10,4 +10,3 @@ "use strict"; | ||
function isRepeatableDirective(directive, directives) { | ||
var _a; | ||
return !!((_a = directives === null || directives === void 0 ? void 0 : directives[directive.name.value]) === null || _a === void 0 ? void 0 : _a.repeatable); | ||
return !!directives?.[directive.name.value]?.repeatable; | ||
} | ||
@@ -14,0 +13,0 @@ function nameAlreadyExists(name, namesArr) { |
@@ -7,3 +7,3 @@ "use strict"; | ||
function mergeEnumValues(first, second, config, directives) { | ||
if (config === null || config === void 0 ? void 0 : config.consistentEnumMerge) { | ||
if (config?.consistentEnumMerge) { | ||
const reversed = []; | ||
@@ -10,0 +10,0 @@ if (first) { |
@@ -12,3 +12,3 @@ "use strict"; | ||
description: e1['description'] || e2['description'], | ||
kind: (config === null || config === void 0 ? void 0 : config.convertExtensions) || e1.kind === 'EnumTypeDefinition' || e2.kind === 'EnumTypeDefinition' | ||
kind: config?.convertExtensions || e1.kind === 'EnumTypeDefinition' || e2.kind === 'EnumTypeDefinition' | ||
? 'EnumTypeDefinition' | ||
@@ -21,3 +21,3 @@ : 'EnumTypeExtension', | ||
} | ||
return (config === null || config === void 0 ? void 0 : config.convertExtensions) | ||
return config?.convertExtensions | ||
? { | ||
@@ -24,0 +24,0 @@ ...e1, |
@@ -20,5 +20,5 @@ "use strict"; | ||
const [existing, existingIndex] = fieldAlreadyExists(result, field); | ||
if (existing && !(config === null || config === void 0 ? void 0 : config.ignoreFieldConflicts)) { | ||
const newField = ((config === null || config === void 0 ? void 0 : config.onFieldTypeConflict) && config.onFieldTypeConflict(existing, field, type, config === null || config === void 0 ? void 0 : config.throwOnConflict)) || | ||
preventConflicts(type, existing, field, config === null || config === void 0 ? void 0 : config.throwOnConflict); | ||
if (existing && !config?.ignoreFieldConflicts) { | ||
const newField = (config?.onFieldTypeConflict && config.onFieldTypeConflict(existing, field, type, config?.throwOnConflict)) || | ||
preventConflicts(type, existing, field, config?.throwOnConflict); | ||
newField.arguments = (0, arguments_js_1.mergeArguments)(field['arguments'] || [], existing['arguments'] || [], config); | ||
@@ -25,0 +25,0 @@ newField.directives = (0, directives_js_1.mergeDirectives)(field.directives, existing.directives, config, directives); |
@@ -13,3 +13,3 @@ "use strict"; | ||
description: node['description'] || existingNode['description'], | ||
kind: (config === null || config === void 0 ? void 0 : config.convertExtensions) || | ||
kind: config?.convertExtensions || | ||
node.kind === 'InputObjectTypeDefinition' || | ||
@@ -28,3 +28,3 @@ existingNode.kind === 'InputObjectTypeDefinition' | ||
} | ||
return (config === null || config === void 0 ? void 0 : config.convertExtensions) | ||
return config?.convertExtensions | ||
? { | ||
@@ -31,0 +31,0 @@ ...node, |
@@ -14,3 +14,3 @@ "use strict"; | ||
description: node['description'] || existingNode['description'], | ||
kind: (config === null || config === void 0 ? void 0 : config.convertExtensions) || | ||
kind: config?.convertExtensions || | ||
node.kind === 'InterfaceTypeDefinition' || | ||
@@ -32,3 +32,3 @@ existingNode.kind === 'InterfaceTypeDefinition' | ||
} | ||
return (config === null || config === void 0 ? void 0 : config.convertExtensions) | ||
return config?.convertExtensions | ||
? { | ||
@@ -35,0 +35,0 @@ ...node, |
@@ -20,8 +20,7 @@ "use strict"; | ||
function mergeGraphQLNodes(nodes, config, directives = {}) { | ||
var _a, _b, _c; | ||
const mergedResultMap = directives; | ||
for (const nodeDefinition of nodes) { | ||
if (isNamedDefinitionNode(nodeDefinition)) { | ||
const name = (_a = nodeDefinition.name) === null || _a === void 0 ? void 0 : _a.value; | ||
if (config === null || config === void 0 ? void 0 : config.commentDescriptions) { | ||
const name = nodeDefinition.name?.value; | ||
if (config?.commentDescriptions) { | ||
(0, utils_1.collectComment)(nodeDefinition); | ||
@@ -32,3 +31,3 @@ } | ||
} | ||
if (((_b = config === null || config === void 0 ? void 0 : config.exclusions) === null || _b === void 0 ? void 0 : _b.includes(name + '.*')) || ((_c = config === null || config === void 0 ? void 0 : config.exclusions) === null || _c === void 0 ? void 0 : _c.includes(name))) { | ||
if (config?.exclusions?.includes(name + '.*') || config?.exclusions?.includes(name)) { | ||
delete mergedResultMap[name]; | ||
@@ -35,0 +34,0 @@ } |
@@ -22,3 +22,3 @@ "use strict"; | ||
let result; | ||
if (config === null || config === void 0 ? void 0 : config.commentDescriptions) { | ||
if (config?.commentDescriptions) { | ||
result = (0, utils_1.printWithComments)(doc); | ||
@@ -70,3 +70,2 @@ } | ||
function mergeGraphQLTypes(typeSource, config) { | ||
var _a, _b, _c; | ||
(0, utils_1.resetComments)(); | ||
@@ -76,3 +75,3 @@ const { allDirectives, allNodes } = visitTypeSources(typeSource, config); | ||
const mergedNodes = (0, merge_nodes_js_1.mergeGraphQLNodes)(allNodes, config, mergedDirectives); | ||
if (config === null || config === void 0 ? void 0 : config.useSchemaDefinition) { | ||
if (config?.useSchemaDefinition) { | ||
// XXX: right now we don't handle multiple schema definitions | ||
@@ -101,7 +100,7 @@ const schemaDef = mergedNodes[merge_nodes_js_1.schemaDefSymbol] || { | ||
} | ||
if (((_a = schemaDef === null || schemaDef === void 0 ? void 0 : schemaDef.operationTypes) === null || _a === void 0 ? void 0 : _a.length) != null && schemaDef.operationTypes.length > 0) { | ||
if (schemaDef?.operationTypes?.length != null && schemaDef.operationTypes.length > 0) { | ||
mergedNodes[merge_nodes_js_1.schemaDefSymbol] = schemaDef; | ||
} | ||
} | ||
if ((config === null || config === void 0 ? void 0 : config.forceSchemaDefinition) && !((_c = (_b = mergedNodes[merge_nodes_js_1.schemaDefSymbol]) === null || _b === void 0 ? void 0 : _b.operationTypes) === null || _c === void 0 ? void 0 : _c.length)) { | ||
if (config?.forceSchemaDefinition && !mergedNodes[merge_nodes_js_1.schemaDefSymbol]?.operationTypes?.length) { | ||
mergedNodes[merge_nodes_js_1.schemaDefSymbol] = { | ||
@@ -125,5 +124,5 @@ kind: graphql_1.Kind.SCHEMA_DEFINITION, | ||
const mergedNodeDefinitions = Object.values(mergedNodes); | ||
if (config === null || config === void 0 ? void 0 : config.sort) { | ||
if (config?.sort) { | ||
const sortFn = typeof config.sort === 'function' ? config.sort : utils_js_1.defaultStringComparator; | ||
mergedNodeDefinitions.sort((a, b) => { var _a, _b; return sortFn((_a = a.name) === null || _a === void 0 ? void 0 : _a.value, (_b = b.name) === null || _b === void 0 ? void 0 : _b.value); }); | ||
mergedNodeDefinitions.sort((a, b) => sortFn(a.name?.value, b.name?.value)); | ||
} | ||
@@ -130,0 +129,0 @@ return mergedNodeDefinitions; |
@@ -11,3 +11,3 @@ "use strict"; | ||
description: node['description'] || existingNode['description'], | ||
kind: (config === null || config === void 0 ? void 0 : config.convertExtensions) || | ||
kind: config?.convertExtensions || | ||
node.kind === 'ScalarTypeDefinition' || | ||
@@ -21,3 +21,3 @@ existingNode.kind === 'ScalarTypeDefinition' | ||
} | ||
return (config === null || config === void 0 ? void 0 : config.convertExtensions) | ||
return config?.convertExtensions | ||
? { | ||
@@ -24,0 +24,0 @@ ...node, |
@@ -32,3 +32,3 @@ "use strict"; | ||
} | ||
return ((config === null || config === void 0 ? void 0 : config.convertExtensions) | ||
return (config?.convertExtensions | ||
? { | ||
@@ -35,0 +35,0 @@ ...node, |
@@ -14,3 +14,3 @@ "use strict"; | ||
description: node['description'] || existingNode['description'], | ||
kind: (config === null || config === void 0 ? void 0 : config.convertExtensions) || | ||
kind: config?.convertExtensions || | ||
node.kind === 'ObjectTypeDefinition' || | ||
@@ -30,3 +30,3 @@ existingNode.kind === 'ObjectTypeDefinition' | ||
} | ||
return (config === null || config === void 0 ? void 0 : config.convertExtensions) | ||
return config?.convertExtensions | ||
? { | ||
@@ -33,0 +33,0 @@ ...node, |
@@ -14,3 +14,3 @@ "use strict"; | ||
directives: (0, directives_js_1.mergeDirectives)(first.directives, second.directives, config, directives), | ||
kind: (config === null || config === void 0 ? void 0 : config.convertExtensions) || first.kind === 'UnionTypeDefinition' || second.kind === 'UnionTypeDefinition' | ||
kind: config?.convertExtensions || first.kind === 'UnionTypeDefinition' || second.kind === 'UnionTypeDefinition' | ||
? graphql_1.Kind.UNION_TYPE_DEFINITION | ||
@@ -22,3 +22,3 @@ : graphql_1.Kind.UNION_TYPE_EXTENSION, | ||
} | ||
return (config === null || config === void 0 ? void 0 : config.convertExtensions) | ||
return config?.convertExtensions | ||
? { | ||
@@ -25,0 +25,0 @@ ...first, |
@@ -51,3 +51,3 @@ import { mergeDeep } from '@graphql-tools/utils'; | ||
const result = mergeDeep(resolvers, true); | ||
if (options === null || options === void 0 ? void 0 : options.exclusions) { | ||
if (options?.exclusions) { | ||
for (const exclusion of options.exclusions) { | ||
@@ -54,0 +54,0 @@ const [typeName, fieldName] = exclusion.split('.'); |
@@ -15,3 +15,3 @@ import { compareNodes, isSome } from '@graphql-tools/utils'; | ||
} | ||
else if (!(config === null || config === void 0 ? void 0 : config.reverseArguments)) { | ||
else if (!config?.reverseArguments) { | ||
acc[dupIndex] = current; | ||
@@ -18,0 +18,0 @@ } |
@@ -7,4 +7,3 @@ import { print } from 'graphql'; | ||
function isRepeatableDirective(directive, directives) { | ||
var _a; | ||
return !!((_a = directives === null || directives === void 0 ? void 0 : directives[directive.name.value]) === null || _a === void 0 ? void 0 : _a.repeatable); | ||
return !!directives?.[directive.name.value]?.repeatable; | ||
} | ||
@@ -11,0 +10,0 @@ function nameAlreadyExists(name, namesArr) { |
import { mergeDirectives } from './directives.js'; | ||
import { compareNodes } from '@graphql-tools/utils'; | ||
export function mergeEnumValues(first, second, config, directives) { | ||
if (config === null || config === void 0 ? void 0 : config.consistentEnumMerge) { | ||
if (config?.consistentEnumMerge) { | ||
const reversed = []; | ||
@@ -6,0 +6,0 @@ if (first) { |
@@ -9,3 +9,3 @@ import { Kind } from 'graphql'; | ||
description: e1['description'] || e2['description'], | ||
kind: (config === null || config === void 0 ? void 0 : config.convertExtensions) || e1.kind === 'EnumTypeDefinition' || e2.kind === 'EnumTypeDefinition' | ||
kind: config?.convertExtensions || e1.kind === 'EnumTypeDefinition' || e2.kind === 'EnumTypeDefinition' | ||
? 'EnumTypeDefinition' | ||
@@ -18,3 +18,3 @@ : 'EnumTypeExtension', | ||
} | ||
return (config === null || config === void 0 ? void 0 : config.convertExtensions) | ||
return config?.convertExtensions | ||
? { | ||
@@ -21,0 +21,0 @@ ...e1, |
@@ -17,5 +17,5 @@ import { extractType, isWrappingTypeNode, isListTypeNode, isNonNullTypeNode, printTypeNode } from './utils.js'; | ||
const [existing, existingIndex] = fieldAlreadyExists(result, field); | ||
if (existing && !(config === null || config === void 0 ? void 0 : config.ignoreFieldConflicts)) { | ||
const newField = ((config === null || config === void 0 ? void 0 : config.onFieldTypeConflict) && config.onFieldTypeConflict(existing, field, type, config === null || config === void 0 ? void 0 : config.throwOnConflict)) || | ||
preventConflicts(type, existing, field, config === null || config === void 0 ? void 0 : config.throwOnConflict); | ||
if (existing && !config?.ignoreFieldConflicts) { | ||
const newField = (config?.onFieldTypeConflict && config.onFieldTypeConflict(existing, field, type, config?.throwOnConflict)) || | ||
preventConflicts(type, existing, field, config?.throwOnConflict); | ||
newField.arguments = mergeArguments(field['arguments'] || [], existing['arguments'] || [], config); | ||
@@ -22,0 +22,0 @@ newField.directives = mergeDirectives(field.directives, existing.directives, config, directives); |
@@ -10,3 +10,3 @@ import { Kind, } from 'graphql'; | ||
description: node['description'] || existingNode['description'], | ||
kind: (config === null || config === void 0 ? void 0 : config.convertExtensions) || | ||
kind: config?.convertExtensions || | ||
node.kind === 'InputObjectTypeDefinition' || | ||
@@ -25,3 +25,3 @@ existingNode.kind === 'InputObjectTypeDefinition' | ||
} | ||
return (config === null || config === void 0 ? void 0 : config.convertExtensions) | ||
return config?.convertExtensions | ||
? { | ||
@@ -28,0 +28,0 @@ ...node, |
@@ -11,3 +11,3 @@ import { Kind } from 'graphql'; | ||
description: node['description'] || existingNode['description'], | ||
kind: (config === null || config === void 0 ? void 0 : config.convertExtensions) || | ||
kind: config?.convertExtensions || | ||
node.kind === 'InterfaceTypeDefinition' || | ||
@@ -29,3 +29,3 @@ existingNode.kind === 'InterfaceTypeDefinition' | ||
} | ||
return (config === null || config === void 0 ? void 0 : config.convertExtensions) | ||
return config?.convertExtensions | ||
? { | ||
@@ -32,0 +32,0 @@ ...node, |
@@ -16,8 +16,7 @@ import { Kind } from 'graphql'; | ||
export function mergeGraphQLNodes(nodes, config, directives = {}) { | ||
var _a, _b, _c; | ||
const mergedResultMap = directives; | ||
for (const nodeDefinition of nodes) { | ||
if (isNamedDefinitionNode(nodeDefinition)) { | ||
const name = (_a = nodeDefinition.name) === null || _a === void 0 ? void 0 : _a.value; | ||
if (config === null || config === void 0 ? void 0 : config.commentDescriptions) { | ||
const name = nodeDefinition.name?.value; | ||
if (config?.commentDescriptions) { | ||
collectComment(nodeDefinition); | ||
@@ -28,3 +27,3 @@ } | ||
} | ||
if (((_b = config === null || config === void 0 ? void 0 : config.exclusions) === null || _b === void 0 ? void 0 : _b.includes(name + '.*')) || ((_c = config === null || config === void 0 ? void 0 : config.exclusions) === null || _c === void 0 ? void 0 : _c.includes(name))) { | ||
if (config?.exclusions?.includes(name + '.*') || config?.exclusions?.includes(name)) { | ||
delete mergedResultMap[name]; | ||
@@ -31,0 +30,0 @@ } |
@@ -19,3 +19,3 @@ import { parse, Kind, isSchema, isDefinitionNode, } from 'graphql'; | ||
let result; | ||
if (config === null || config === void 0 ? void 0 : config.commentDescriptions) { | ||
if (config?.commentDescriptions) { | ||
result = printWithComments(doc); | ||
@@ -66,3 +66,2 @@ } | ||
export function mergeGraphQLTypes(typeSource, config) { | ||
var _a, _b, _c; | ||
resetComments(); | ||
@@ -72,3 +71,3 @@ const { allDirectives, allNodes } = visitTypeSources(typeSource, config); | ||
const mergedNodes = mergeGraphQLNodes(allNodes, config, mergedDirectives); | ||
if (config === null || config === void 0 ? void 0 : config.useSchemaDefinition) { | ||
if (config?.useSchemaDefinition) { | ||
// XXX: right now we don't handle multiple schema definitions | ||
@@ -97,7 +96,7 @@ const schemaDef = mergedNodes[schemaDefSymbol] || { | ||
} | ||
if (((_a = schemaDef === null || schemaDef === void 0 ? void 0 : schemaDef.operationTypes) === null || _a === void 0 ? void 0 : _a.length) != null && schemaDef.operationTypes.length > 0) { | ||
if (schemaDef?.operationTypes?.length != null && schemaDef.operationTypes.length > 0) { | ||
mergedNodes[schemaDefSymbol] = schemaDef; | ||
} | ||
} | ||
if ((config === null || config === void 0 ? void 0 : config.forceSchemaDefinition) && !((_c = (_b = mergedNodes[schemaDefSymbol]) === null || _b === void 0 ? void 0 : _b.operationTypes) === null || _c === void 0 ? void 0 : _c.length)) { | ||
if (config?.forceSchemaDefinition && !mergedNodes[schemaDefSymbol]?.operationTypes?.length) { | ||
mergedNodes[schemaDefSymbol] = { | ||
@@ -121,7 +120,7 @@ kind: Kind.SCHEMA_DEFINITION, | ||
const mergedNodeDefinitions = Object.values(mergedNodes); | ||
if (config === null || config === void 0 ? void 0 : config.sort) { | ||
if (config?.sort) { | ||
const sortFn = typeof config.sort === 'function' ? config.sort : defaultStringComparator; | ||
mergedNodeDefinitions.sort((a, b) => { var _a, _b; return sortFn((_a = a.name) === null || _a === void 0 ? void 0 : _a.value, (_b = b.name) === null || _b === void 0 ? void 0 : _b.value); }); | ||
mergedNodeDefinitions.sort((a, b) => sortFn(a.name?.value, b.name?.value)); | ||
} | ||
return mergedNodeDefinitions; | ||
} |
@@ -8,3 +8,3 @@ import { Kind } from 'graphql'; | ||
description: node['description'] || existingNode['description'], | ||
kind: (config === null || config === void 0 ? void 0 : config.convertExtensions) || | ||
kind: config?.convertExtensions || | ||
node.kind === 'ScalarTypeDefinition' || | ||
@@ -18,3 +18,3 @@ existingNode.kind === 'ScalarTypeDefinition' | ||
} | ||
return (config === null || config === void 0 ? void 0 : config.convertExtensions) | ||
return config?.convertExtensions | ||
? { | ||
@@ -21,0 +21,0 @@ ...node, |
@@ -29,3 +29,3 @@ import { Kind, } from 'graphql'; | ||
} | ||
return ((config === null || config === void 0 ? void 0 : config.convertExtensions) | ||
return (config?.convertExtensions | ||
? { | ||
@@ -32,0 +32,0 @@ ...node, |
@@ -11,3 +11,3 @@ import { Kind } from 'graphql'; | ||
description: node['description'] || existingNode['description'], | ||
kind: (config === null || config === void 0 ? void 0 : config.convertExtensions) || | ||
kind: config?.convertExtensions || | ||
node.kind === 'ObjectTypeDefinition' || | ||
@@ -27,3 +27,3 @@ existingNode.kind === 'ObjectTypeDefinition' | ||
} | ||
return (config === null || config === void 0 ? void 0 : config.convertExtensions) | ||
return config?.convertExtensions | ||
? { | ||
@@ -30,0 +30,0 @@ ...node, |
@@ -11,3 +11,3 @@ import { Kind } from 'graphql'; | ||
directives: mergeDirectives(first.directives, second.directives, config, directives), | ||
kind: (config === null || config === void 0 ? void 0 : config.convertExtensions) || first.kind === 'UnionTypeDefinition' || second.kind === 'UnionTypeDefinition' | ||
kind: config?.convertExtensions || first.kind === 'UnionTypeDefinition' || second.kind === 'UnionTypeDefinition' | ||
? Kind.UNION_TYPE_DEFINITION | ||
@@ -19,3 +19,3 @@ : Kind.UNION_TYPE_EXTENSION, | ||
} | ||
return (config === null || config === void 0 ? void 0 : config.convertExtensions) | ||
return config?.convertExtensions | ||
? { | ||
@@ -22,0 +22,0 @@ ...first, |
{ | ||
"name": "@graphql-tools/merge", | ||
"version": "9.0.0-rc-20230519104353-b09f3180", | ||
"version": "9.0.0-rc-20230519104627-f6fea064", | ||
"description": "A set of utils for faster development of GraphQL tools", | ||
@@ -10,3 +10,3 @@ "sideEffects": false, | ||
"dependencies": { | ||
"@graphql-tools/utils": "10.0.0-rc-20230519104353-b09f3180", | ||
"@graphql-tools/utils": "10.0.0-rc-20230519104627-f6fea064", | ||
"tslib": "^2.4.0" | ||
@@ -13,0 +13,0 @@ }, |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
96366
1925
+ Added@graphql-tools/utils@10.0.0-rc-20230519104627-f6fea064(transitive)
+ Added@graphql-typed-document-node/core@3.2.0(transitive)
Updated@graphql-tools/utils@10.0.0-rc-20230519104627-f6fea064