@graphql-tools/merge 9.0.0 → 9.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cjs/extensions.js +2 -2
- package/cjs/merge-resolvers.js +2 -1
- package/cjs/typedefs-mergers/directives.js +2 -1
- package/cjs/typedefs-mergers/enum-values.js +1 -1
- package/cjs/typedefs-mergers/enum.js +3 -1
- package/cjs/typedefs-mergers/fields.js +4 -3
- package/cjs/typedefs-mergers/input-type.js +1 -1
- package/cjs/typedefs-mergers/interface.js +1 -1
- package/cjs/typedefs-mergers/merge-nodes.js +7 -6
- package/cjs/typedefs-mergers/merge-typedefs.js +2 -2
- package/cjs/typedefs-mergers/schema-def.js +2 -1
- package/cjs/typedefs-mergers/type.js +1 -1
- package/cjs/typedefs-mergers/union.js +3 -1
- package/cjs/typedefs-mergers/utils.js +1 -1
- package/esm/extensions.js +2 -2
- package/esm/merge-resolvers.js +2 -1
- package/esm/typedefs-mergers/directives.js +3 -2
- package/esm/typedefs-mergers/enum-values.js +1 -1
- package/esm/typedefs-mergers/enum.js +4 -2
- package/esm/typedefs-mergers/fields.js +4 -3
- package/esm/typedefs-mergers/input-type.js +1 -1
- package/esm/typedefs-mergers/interface.js +2 -2
- package/esm/typedefs-mergers/merge-nodes.js +8 -7
- package/esm/typedefs-mergers/merge-typedefs.js +3 -3
- package/esm/typedefs-mergers/scalar.js +1 -1
- package/esm/typedefs-mergers/schema-def.js +2 -1
- package/esm/typedefs-mergers/type.js +2 -2
- package/esm/typedefs-mergers/union.js +4 -2
- package/esm/typedefs-mergers/utils.js +1 -1
- package/package.json +2 -2
- package/typings/typedefs-mergers/directives.d.cts +1 -1
- package/typings/typedefs-mergers/directives.d.ts +1 -1
- package/typings/typedefs-mergers/fields.d.cts +1 -1
- package/typings/typedefs-mergers/fields.d.ts +1 -1
- package/typings/typedefs-mergers/input-type.d.cts +1 -1
- package/typings/typedefs-mergers/input-type.d.ts +1 -1
- package/typings/typedefs-mergers/interface.d.cts +1 -1
- package/typings/typedefs-mergers/interface.d.ts +1 -1
- package/typings/typedefs-mergers/merge-nodes.d.cts +1 -1
- package/typings/typedefs-mergers/merge-nodes.d.ts +1 -1
- package/typings/typedefs-mergers/merge-typedefs.d.cts +1 -1
- package/typings/typedefs-mergers/merge-typedefs.d.ts +1 -1
- package/typings/typedefs-mergers/type.d.cts +1 -1
- package/typings/typedefs-mergers/type.d.ts +1 -1
- package/typings/typedefs-mergers/utils.d.cts +1 -1
- package/typings/typedefs-mergers/utils.d.ts +1 -1
package/cjs/extensions.js
CHANGED
|
@@ -5,14 +5,14 @@ const utils_1 = require("@graphql-tools/utils");
|
|
|
5
5
|
var utils_2 = require("@graphql-tools/utils");
|
|
6
6
|
Object.defineProperty(exports, "extractExtensionsFromSchema", { enumerable: true, get: function () { return utils_2.extractExtensionsFromSchema; } });
|
|
7
7
|
function mergeExtensions(extensions) {
|
|
8
|
-
return (0, utils_1.mergeDeep)(extensions);
|
|
8
|
+
return (0, utils_1.mergeDeep)(extensions, false, true);
|
|
9
9
|
}
|
|
10
10
|
exports.mergeExtensions = mergeExtensions;
|
|
11
11
|
function applyExtensionObject(obj, extensions) {
|
|
12
12
|
if (!obj) {
|
|
13
13
|
return;
|
|
14
14
|
}
|
|
15
|
-
obj.extensions = (0, utils_1.mergeDeep)([obj.extensions || {}, extensions || {}]);
|
|
15
|
+
obj.extensions = (0, utils_1.mergeDeep)([obj.extensions || {}, extensions || {}], false, true);
|
|
16
16
|
}
|
|
17
17
|
function applyExtensions(schema, extensions) {
|
|
18
18
|
applyExtensionObject(schema, extensions.schemaExtensions);
|
package/cjs/merge-resolvers.js
CHANGED
|
@@ -32,7 +32,8 @@ const utils_1 = require("@graphql-tools/utils");
|
|
|
32
32
|
* ```
|
|
33
33
|
*/
|
|
34
34
|
function mergeResolvers(resolversDefinitions, options) {
|
|
35
|
-
if (!resolversDefinitions ||
|
|
35
|
+
if (!resolversDefinitions ||
|
|
36
|
+
(Array.isArray(resolversDefinitions) && resolversDefinitions.length === 0)) {
|
|
36
37
|
return {};
|
|
37
38
|
}
|
|
38
39
|
if (!Array.isArray(resolversDefinitions)) {
|
|
@@ -56,7 +56,8 @@ function mergeDirectives(d1 = [], d2 = [], config, directives) {
|
|
|
56
56
|
const asFirst = reverseOrder ? d2 : d1;
|
|
57
57
|
const result = deduplicateDirectives([...asNext], directives);
|
|
58
58
|
for (const directive of asFirst) {
|
|
59
|
-
if (directiveAlreadyExists(result, directive) &&
|
|
59
|
+
if (directiveAlreadyExists(result, directive) &&
|
|
60
|
+
!isRepeatableDirective(directive, directives)) {
|
|
60
61
|
const existingDirectiveIndex = result.findIndex(d => d.name.value === directive.name.value);
|
|
61
62
|
const existingDirective = result[existingDirectiveIndex];
|
|
62
63
|
result[existingDirectiveIndex].arguments = mergeArguments(directive.arguments || [], existingDirective.arguments || []);
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.mergeEnumValues = void 0;
|
|
4
|
-
const directives_js_1 = require("./directives.js");
|
|
5
4
|
const utils_1 = require("@graphql-tools/utils");
|
|
5
|
+
const directives_js_1 = require("./directives.js");
|
|
6
6
|
function mergeEnumValues(first, second, config, directives) {
|
|
7
7
|
if (config?.consistentEnumMerge) {
|
|
8
8
|
const reversed = [];
|
|
@@ -9,7 +9,9 @@ function mergeEnum(e1, e2, config, directives) {
|
|
|
9
9
|
return {
|
|
10
10
|
name: e1.name,
|
|
11
11
|
description: e1['description'] || e2['description'],
|
|
12
|
-
kind: config?.convertExtensions ||
|
|
12
|
+
kind: config?.convertExtensions ||
|
|
13
|
+
e1.kind === 'EnumTypeDefinition' ||
|
|
14
|
+
e2.kind === 'EnumTypeDefinition'
|
|
13
15
|
? 'EnumTypeDefinition'
|
|
14
16
|
: 'EnumTypeExtension',
|
|
15
17
|
loc: e1.loc,
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.mergeFields = void 0;
|
|
4
|
-
const utils_js_1 = require("./utils.js");
|
|
5
|
-
const directives_js_1 = require("./directives.js");
|
|
6
4
|
const utils_1 = require("@graphql-tools/utils");
|
|
7
5
|
const arguments_js_1 = require("./arguments.js");
|
|
6
|
+
const directives_js_1 = require("./directives.js");
|
|
7
|
+
const utils_js_1 = require("./utils.js");
|
|
8
8
|
function fieldAlreadyExists(fieldsArr, otherField) {
|
|
9
9
|
const resultIndex = fieldsArr.findIndex(field => field.name.value === otherField.name.value);
|
|
10
10
|
return [resultIndex > -1 ? fieldsArr[resultIndex] : null, resultIndex];
|
|
@@ -18,7 +18,8 @@ function mergeFields(type, f1, f2, config, directives) {
|
|
|
18
18
|
for (const field of f1) {
|
|
19
19
|
const [existing, existingIndex] = fieldAlreadyExists(result, field);
|
|
20
20
|
if (existing && !config?.ignoreFieldConflicts) {
|
|
21
|
-
const newField = (config?.onFieldTypeConflict &&
|
|
21
|
+
const newField = (config?.onFieldTypeConflict &&
|
|
22
|
+
config.onFieldTypeConflict(existing, field, type, config?.throwOnConflict)) ||
|
|
22
23
|
preventConflicts(type, existing, field, config?.throwOnConflict);
|
|
23
24
|
newField.arguments = (0, arguments_js_1.mergeArguments)(field['arguments'] || [], existing['arguments'] || [], config);
|
|
24
25
|
newField.directives = (0, directives_js_1.mergeDirectives)(field.directives, existing.directives, config, directives);
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.mergeInputType = void 0;
|
|
4
4
|
const graphql_1 = require("graphql");
|
|
5
|
-
const fields_js_1 = require("./fields.js");
|
|
6
5
|
const directives_js_1 = require("./directives.js");
|
|
6
|
+
const fields_js_1 = require("./fields.js");
|
|
7
7
|
function mergeInputType(node, existingNode, config, directives) {
|
|
8
8
|
if (existingNode) {
|
|
9
9
|
try {
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.mergeInterface = void 0;
|
|
4
4
|
const graphql_1 = require("graphql");
|
|
5
|
-
const fields_js_1 = require("./fields.js");
|
|
6
5
|
const directives_js_1 = require("./directives.js");
|
|
6
|
+
const fields_js_1 = require("./fields.js");
|
|
7
7
|
const merge_named_type_array_js_1 = require("./merge-named-type-array.js");
|
|
8
8
|
function mergeInterface(node, existingNode, config, directives) {
|
|
9
9
|
if (existingNode) {
|
|
@@ -2,15 +2,15 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.mergeGraphQLNodes = exports.isNamedDefinitionNode = exports.schemaDefSymbol = void 0;
|
|
4
4
|
const graphql_1 = require("graphql");
|
|
5
|
-
const
|
|
5
|
+
const utils_1 = require("@graphql-tools/utils");
|
|
6
|
+
const directives_js_1 = require("./directives.js");
|
|
6
7
|
const enum_js_1 = require("./enum.js");
|
|
7
|
-
const scalar_js_1 = require("./scalar.js");
|
|
8
|
-
const union_js_1 = require("./union.js");
|
|
9
8
|
const input_type_js_1 = require("./input-type.js");
|
|
10
9
|
const interface_js_1 = require("./interface.js");
|
|
11
|
-
const
|
|
10
|
+
const scalar_js_1 = require("./scalar.js");
|
|
12
11
|
const schema_def_js_1 = require("./schema-def.js");
|
|
13
|
-
const
|
|
12
|
+
const type_js_1 = require("./type.js");
|
|
13
|
+
const union_js_1 = require("./union.js");
|
|
14
14
|
exports.schemaDefSymbol = 'SCHEMA_DEF_SYMBOL';
|
|
15
15
|
function isNamedDefinitionNode(definitionNode) {
|
|
16
16
|
return 'name' in definitionNode;
|
|
@@ -62,7 +62,8 @@ function mergeGraphQLNodes(nodes, config, directives = {}) {
|
|
|
62
62
|
}
|
|
63
63
|
}
|
|
64
64
|
}
|
|
65
|
-
else if (nodeDefinition.kind === graphql_1.Kind.SCHEMA_DEFINITION ||
|
|
65
|
+
else if (nodeDefinition.kind === graphql_1.Kind.SCHEMA_DEFINITION ||
|
|
66
|
+
nodeDefinition.kind === graphql_1.Kind.SCHEMA_EXTENSION) {
|
|
66
67
|
mergedResultMap[exports.schemaDefSymbol] = (0, schema_def_js_1.mergeSchemaDefs)(nodeDefinition, mergedResultMap[exports.schemaDefSymbol], config);
|
|
67
68
|
}
|
|
68
69
|
}
|
|
@@ -2,10 +2,10 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.mergeGraphQLTypes = exports.mergeTypeDefs = void 0;
|
|
4
4
|
const graphql_1 = require("graphql");
|
|
5
|
-
const utils_js_1 = require("./utils.js");
|
|
6
|
-
const merge_nodes_js_1 = require("./merge-nodes.js");
|
|
7
5
|
const utils_1 = require("@graphql-tools/utils");
|
|
6
|
+
const merge_nodes_js_1 = require("./merge-nodes.js");
|
|
8
7
|
const schema_def_js_1 = require("./schema-def.js");
|
|
8
|
+
const utils_js_1 = require("./utils.js");
|
|
9
9
|
function mergeTypeDefs(typeSource, config) {
|
|
10
10
|
(0, utils_1.resetComments)();
|
|
11
11
|
const doc = {
|
|
@@ -11,7 +11,8 @@ exports.DEFAULT_OPERATION_TYPE_NAME_MAP = {
|
|
|
11
11
|
function mergeOperationTypes(opNodeList = [], existingOpNodeList = []) {
|
|
12
12
|
const finalOpNodeList = [];
|
|
13
13
|
for (const opNodeType in exports.DEFAULT_OPERATION_TYPE_NAME_MAP) {
|
|
14
|
-
const opNode = opNodeList.find(n => n.operation === opNodeType) ||
|
|
14
|
+
const opNode = opNodeList.find(n => n.operation === opNodeType) ||
|
|
15
|
+
existingOpNodeList.find(n => n.operation === opNodeType);
|
|
15
16
|
if (opNode) {
|
|
16
17
|
finalOpNodeList.push(opNode);
|
|
17
18
|
}
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.mergeType = void 0;
|
|
4
4
|
const graphql_1 = require("graphql");
|
|
5
|
-
const fields_js_1 = require("./fields.js");
|
|
6
5
|
const directives_js_1 = require("./directives.js");
|
|
6
|
+
const fields_js_1 = require("./fields.js");
|
|
7
7
|
const merge_named_type_array_js_1 = require("./merge-named-type-array.js");
|
|
8
8
|
function mergeType(node, existingNode, config, directives) {
|
|
9
9
|
if (existingNode) {
|
|
@@ -11,7 +11,9 @@ function mergeUnion(first, second, config, directives) {
|
|
|
11
11
|
description: first['description'] || second['description'],
|
|
12
12
|
// ConstXNode has been introduced in v16 but it is not compatible with XNode so we do `as any` for backwards compatibility
|
|
13
13
|
directives: (0, directives_js_1.mergeDirectives)(first.directives, second.directives, config, directives),
|
|
14
|
-
kind: config?.convertExtensions ||
|
|
14
|
+
kind: config?.convertExtensions ||
|
|
15
|
+
first.kind === 'UnionTypeDefinition' ||
|
|
16
|
+
second.kind === 'UnionTypeDefinition'
|
|
15
17
|
? graphql_1.Kind.UNION_TYPE_DEFINITION
|
|
16
18
|
: graphql_1.Kind.UNION_TYPE_EXTENSION,
|
|
17
19
|
loc: first.loc,
|
|
@@ -45,7 +45,7 @@ var CompareVal;
|
|
|
45
45
|
CompareVal[CompareVal["A_SMALLER_THAN_B"] = -1] = "A_SMALLER_THAN_B";
|
|
46
46
|
CompareVal[CompareVal["A_EQUALS_B"] = 0] = "A_EQUALS_B";
|
|
47
47
|
CompareVal[CompareVal["A_GREATER_THAN_B"] = 1] = "A_GREATER_THAN_B";
|
|
48
|
-
})(CompareVal
|
|
48
|
+
})(CompareVal || (exports.CompareVal = CompareVal = {}));
|
|
49
49
|
function defaultStringComparator(a, b) {
|
|
50
50
|
if (a == null && b == null) {
|
|
51
51
|
return CompareVal.A_EQUALS_B;
|
package/esm/extensions.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { mergeDeep } from '@graphql-tools/utils';
|
|
2
2
|
export { extractExtensionsFromSchema } from '@graphql-tools/utils';
|
|
3
3
|
export function mergeExtensions(extensions) {
|
|
4
|
-
return mergeDeep(extensions);
|
|
4
|
+
return mergeDeep(extensions, false, true);
|
|
5
5
|
}
|
|
6
6
|
function applyExtensionObject(obj, extensions) {
|
|
7
7
|
if (!obj) {
|
|
8
8
|
return;
|
|
9
9
|
}
|
|
10
|
-
obj.extensions = mergeDeep([obj.extensions || {}, extensions || {}]);
|
|
10
|
+
obj.extensions = mergeDeep([obj.extensions || {}, extensions || {}], false, true);
|
|
11
11
|
}
|
|
12
12
|
export function applyExtensions(schema, extensions) {
|
|
13
13
|
applyExtensionObject(schema, extensions.schemaExtensions);
|
package/esm/merge-resolvers.js
CHANGED
|
@@ -29,7 +29,8 @@ import { mergeDeep } from '@graphql-tools/utils';
|
|
|
29
29
|
* ```
|
|
30
30
|
*/
|
|
31
31
|
export function mergeResolvers(resolversDefinitions, options) {
|
|
32
|
-
if (!resolversDefinitions ||
|
|
32
|
+
if (!resolversDefinitions ||
|
|
33
|
+
(Array.isArray(resolversDefinitions) && resolversDefinitions.length === 0)) {
|
|
33
34
|
return {};
|
|
34
35
|
}
|
|
35
36
|
if (!Array.isArray(resolversDefinitions)) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { print } from 'graphql';
|
|
1
|
+
import { print, } from 'graphql';
|
|
2
2
|
import { isSome } from '@graphql-tools/utils';
|
|
3
3
|
function directiveAlreadyExists(directivesArr, otherDirective) {
|
|
4
4
|
return !!directivesArr.find(directive => directive.name.value === otherDirective.name.value);
|
|
@@ -53,7 +53,8 @@ export function mergeDirectives(d1 = [], d2 = [], config, directives) {
|
|
|
53
53
|
const asFirst = reverseOrder ? d2 : d1;
|
|
54
54
|
const result = deduplicateDirectives([...asNext], directives);
|
|
55
55
|
for (const directive of asFirst) {
|
|
56
|
-
if (directiveAlreadyExists(result, directive) &&
|
|
56
|
+
if (directiveAlreadyExists(result, directive) &&
|
|
57
|
+
!isRepeatableDirective(directive, directives)) {
|
|
57
58
|
const existingDirectiveIndex = result.findIndex(d => d.name.value === directive.name.value);
|
|
58
59
|
const existingDirective = result[existingDirectiveIndex];
|
|
59
60
|
result[existingDirectiveIndex].arguments = mergeArguments(directive.arguments || [], existingDirective.arguments || []);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { mergeDirectives } from './directives.js';
|
|
2
1
|
import { compareNodes } from '@graphql-tools/utils';
|
|
2
|
+
import { mergeDirectives } from './directives.js';
|
|
3
3
|
export function mergeEnumValues(first, second, config, directives) {
|
|
4
4
|
if (config?.consistentEnumMerge) {
|
|
5
5
|
const reversed = [];
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Kind } from 'graphql';
|
|
1
|
+
import { Kind, } from 'graphql';
|
|
2
2
|
import { mergeDirectives } from './directives.js';
|
|
3
3
|
import { mergeEnumValues } from './enum-values.js';
|
|
4
4
|
export function mergeEnum(e1, e2, config, directives) {
|
|
@@ -6,7 +6,9 @@ export function mergeEnum(e1, e2, config, directives) {
|
|
|
6
6
|
return {
|
|
7
7
|
name: e1.name,
|
|
8
8
|
description: e1['description'] || e2['description'],
|
|
9
|
-
kind: config?.convertExtensions ||
|
|
9
|
+
kind: config?.convertExtensions ||
|
|
10
|
+
e1.kind === 'EnumTypeDefinition' ||
|
|
11
|
+
e2.kind === 'EnumTypeDefinition'
|
|
10
12
|
? 'EnumTypeDefinition'
|
|
11
13
|
: 'EnumTypeExtension',
|
|
12
14
|
loc: e1.loc,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { extractType, isWrappingTypeNode, isListTypeNode, isNonNullTypeNode, printTypeNode } from './utils.js';
|
|
2
|
-
import { mergeDirectives } from './directives.js';
|
|
3
1
|
import { compareNodes } from '@graphql-tools/utils';
|
|
4
2
|
import { mergeArguments } from './arguments.js';
|
|
3
|
+
import { mergeDirectives } from './directives.js';
|
|
4
|
+
import { extractType, isListTypeNode, isNonNullTypeNode, isWrappingTypeNode, printTypeNode, } from './utils.js';
|
|
5
5
|
function fieldAlreadyExists(fieldsArr, otherField) {
|
|
6
6
|
const resultIndex = fieldsArr.findIndex(field => field.name.value === otherField.name.value);
|
|
7
7
|
return [resultIndex > -1 ? fieldsArr[resultIndex] : null, resultIndex];
|
|
@@ -15,7 +15,8 @@ export function mergeFields(type, f1, f2, config, directives) {
|
|
|
15
15
|
for (const field of f1) {
|
|
16
16
|
const [existing, existingIndex] = fieldAlreadyExists(result, field);
|
|
17
17
|
if (existing && !config?.ignoreFieldConflicts) {
|
|
18
|
-
const newField = (config?.onFieldTypeConflict &&
|
|
18
|
+
const newField = (config?.onFieldTypeConflict &&
|
|
19
|
+
config.onFieldTypeConflict(existing, field, type, config?.throwOnConflict)) ||
|
|
19
20
|
preventConflicts(type, existing, field, config?.throwOnConflict);
|
|
20
21
|
newField.arguments = mergeArguments(field['arguments'] || [], existing['arguments'] || [], config);
|
|
21
22
|
newField.directives = mergeDirectives(field.directives, existing.directives, config, directives);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Kind, } from 'graphql';
|
|
2
|
-
import { mergeFields } from './fields.js';
|
|
3
2
|
import { mergeDirectives } from './directives.js';
|
|
3
|
+
import { mergeFields } from './fields.js';
|
|
4
4
|
export function mergeInputType(node, existingNode, config, directives) {
|
|
5
5
|
if (existingNode) {
|
|
6
6
|
try {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { Kind } from 'graphql';
|
|
2
|
-
import { mergeFields } from './fields.js';
|
|
1
|
+
import { Kind, } from 'graphql';
|
|
3
2
|
import { mergeDirectives } from './directives.js';
|
|
3
|
+
import { mergeFields } from './fields.js';
|
|
4
4
|
import { mergeNamedTypeArray } from './merge-named-type-array.js';
|
|
5
5
|
export function mergeInterface(node, existingNode, config, directives) {
|
|
6
6
|
if (existingNode) {
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { Kind } from 'graphql';
|
|
2
|
-
import {
|
|
1
|
+
import { Kind, } from 'graphql';
|
|
2
|
+
import { collectComment } from '@graphql-tools/utils';
|
|
3
|
+
import { mergeDirective } from './directives.js';
|
|
3
4
|
import { mergeEnum } from './enum.js';
|
|
4
|
-
import { mergeScalar } from './scalar.js';
|
|
5
|
-
import { mergeUnion } from './union.js';
|
|
6
5
|
import { mergeInputType } from './input-type.js';
|
|
7
6
|
import { mergeInterface } from './interface.js';
|
|
8
|
-
import {
|
|
7
|
+
import { mergeScalar } from './scalar.js';
|
|
9
8
|
import { mergeSchemaDefs } from './schema-def.js';
|
|
10
|
-
import {
|
|
9
|
+
import { mergeType } from './type.js';
|
|
10
|
+
import { mergeUnion } from './union.js';
|
|
11
11
|
export const schemaDefSymbol = 'SCHEMA_DEF_SYMBOL';
|
|
12
12
|
export function isNamedDefinitionNode(definitionNode) {
|
|
13
13
|
return 'name' in definitionNode;
|
|
@@ -58,7 +58,8 @@ export function mergeGraphQLNodes(nodes, config, directives = {}) {
|
|
|
58
58
|
}
|
|
59
59
|
}
|
|
60
60
|
}
|
|
61
|
-
else if (nodeDefinition.kind === Kind.SCHEMA_DEFINITION ||
|
|
61
|
+
else if (nodeDefinition.kind === Kind.SCHEMA_DEFINITION ||
|
|
62
|
+
nodeDefinition.kind === Kind.SCHEMA_EXTENSION) {
|
|
62
63
|
mergedResultMap[schemaDefSymbol] = mergeSchemaDefs(nodeDefinition, mergedResultMap[schemaDefSymbol], config);
|
|
63
64
|
}
|
|
64
65
|
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { isDefinitionNode, isSchema, Kind, parse, } from 'graphql';
|
|
2
|
+
import { getDocumentNodeFromSchema, isDocumentNode, printWithComments, resetComments, } from '@graphql-tools/utils';
|
|
3
3
|
import { mergeGraphQLNodes, schemaDefSymbol } from './merge-nodes.js';
|
|
4
|
-
import { getDocumentNodeFromSchema, isDocumentNode, resetComments, printWithComments, } from '@graphql-tools/utils';
|
|
5
4
|
import { DEFAULT_OPERATION_TYPE_NAME_MAP } from './schema-def.js';
|
|
5
|
+
import { defaultStringComparator, isSourceTypes, isStringTypes } from './utils.js';
|
|
6
6
|
export function mergeTypeDefs(typeSource, config) {
|
|
7
7
|
resetComments();
|
|
8
8
|
const doc = {
|
|
@@ -8,7 +8,8 @@ export const DEFAULT_OPERATION_TYPE_NAME_MAP = {
|
|
|
8
8
|
function mergeOperationTypes(opNodeList = [], existingOpNodeList = []) {
|
|
9
9
|
const finalOpNodeList = [];
|
|
10
10
|
for (const opNodeType in DEFAULT_OPERATION_TYPE_NAME_MAP) {
|
|
11
|
-
const opNode = opNodeList.find(n => n.operation === opNodeType) ||
|
|
11
|
+
const opNode = opNodeList.find(n => n.operation === opNodeType) ||
|
|
12
|
+
existingOpNodeList.find(n => n.operation === opNodeType);
|
|
12
13
|
if (opNode) {
|
|
13
14
|
finalOpNodeList.push(opNode);
|
|
14
15
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { Kind } from 'graphql';
|
|
2
|
-
import { mergeFields } from './fields.js';
|
|
1
|
+
import { Kind, } from 'graphql';
|
|
3
2
|
import { mergeDirectives } from './directives.js';
|
|
3
|
+
import { mergeFields } from './fields.js';
|
|
4
4
|
import { mergeNamedTypeArray } from './merge-named-type-array.js';
|
|
5
5
|
export function mergeType(node, existingNode, config, directives) {
|
|
6
6
|
if (existingNode) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Kind } from 'graphql';
|
|
1
|
+
import { Kind, } from 'graphql';
|
|
2
2
|
import { mergeDirectives } from './directives.js';
|
|
3
3
|
import { mergeNamedTypeArray } from './merge-named-type-array.js';
|
|
4
4
|
export function mergeUnion(first, second, config, directives) {
|
|
@@ -8,7 +8,9 @@ export function mergeUnion(first, second, config, directives) {
|
|
|
8
8
|
description: first['description'] || second['description'],
|
|
9
9
|
// ConstXNode has been introduced in v16 but it is not compatible with XNode so we do `as any` for backwards compatibility
|
|
10
10
|
directives: mergeDirectives(first.directives, second.directives, config, directives),
|
|
11
|
-
kind: config?.convertExtensions ||
|
|
11
|
+
kind: config?.convertExtensions ||
|
|
12
|
+
first.kind === 'UnionTypeDefinition' ||
|
|
13
|
+
second.kind === 'UnionTypeDefinition'
|
|
12
14
|
? Kind.UNION_TYPE_DEFINITION
|
|
13
15
|
: Kind.UNION_TYPE_EXTENSION,
|
|
14
16
|
loc: first.loc,
|
package/package.json
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@graphql-tools/merge",
|
|
3
|
-
"version": "9.0.
|
|
3
|
+
"version": "9.0.1",
|
|
4
4
|
"description": "A set of utils for faster development of GraphQL tools",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"peerDependencies": {
|
|
7
7
|
"graphql": "^14.0.0 || ^15.0.0 || ^16.0.0 || ^17.0.0"
|
|
8
8
|
},
|
|
9
9
|
"dependencies": {
|
|
10
|
-
"@graphql-tools/utils": "^10.0.
|
|
10
|
+
"@graphql-tools/utils": "^10.0.10",
|
|
11
11
|
"tslib": "^2.4.0"
|
|
12
12
|
},
|
|
13
13
|
"repository": {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { DirectiveDefinitionNode, DirectiveNode } from 'graphql';
|
|
2
2
|
import { Config } from './merge-typedefs.cjs';
|
|
3
3
|
export declare function mergeDirectives(d1?: ReadonlyArray<DirectiveNode>, d2?: ReadonlyArray<DirectiveNode>, config?: Config, directives?: Record<string, DirectiveDefinitionNode>): DirectiveNode[];
|
|
4
4
|
export declare function mergeDirective(node: DirectiveDefinitionNode, existingNode?: DirectiveDefinitionNode): DirectiveDefinitionNode;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { DirectiveDefinitionNode, DirectiveNode } from 'graphql';
|
|
2
2
|
import { Config } from './merge-typedefs.js';
|
|
3
3
|
export declare function mergeDirectives(d1?: ReadonlyArray<DirectiveNode>, d2?: ReadonlyArray<DirectiveNode>, config?: Config, directives?: Record<string, DirectiveDefinitionNode>): DirectiveNode[];
|
|
4
4
|
export declare function mergeDirective(node: DirectiveDefinitionNode, existingNode?: DirectiveDefinitionNode): DirectiveDefinitionNode;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
+
import { DirectiveDefinitionNode, FieldDefinitionNode, InputValueDefinitionNode, NameNode } from 'graphql';
|
|
1
2
|
import { Config } from './merge-typedefs.cjs';
|
|
2
|
-
import { FieldDefinitionNode, InputValueDefinitionNode, NameNode, DirectiveDefinitionNode } from 'graphql';
|
|
3
3
|
type FieldDefNode = FieldDefinitionNode | InputValueDefinitionNode;
|
|
4
4
|
type NamedDefNode = {
|
|
5
5
|
name: NameNode;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
+
import { DirectiveDefinitionNode, FieldDefinitionNode, InputValueDefinitionNode, NameNode } from 'graphql';
|
|
1
2
|
import { Config } from './merge-typedefs.js';
|
|
2
|
-
import { FieldDefinitionNode, InputValueDefinitionNode, NameNode, DirectiveDefinitionNode } from 'graphql';
|
|
3
3
|
type FieldDefNode = FieldDefinitionNode | InputValueDefinitionNode;
|
|
4
4
|
type NamedDefNode = {
|
|
5
5
|
name: NameNode;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
+
import { DirectiveDefinitionNode, InputObjectTypeDefinitionNode, InputObjectTypeExtensionNode } from 'graphql';
|
|
1
2
|
import { Config } from './merge-typedefs.cjs';
|
|
2
|
-
import { InputObjectTypeDefinitionNode, InputObjectTypeExtensionNode, DirectiveDefinitionNode } from 'graphql';
|
|
3
3
|
export declare function mergeInputType(node: InputObjectTypeDefinitionNode | InputObjectTypeExtensionNode, existingNode: InputObjectTypeDefinitionNode | InputObjectTypeExtensionNode, config?: Config, directives?: Record<string, DirectiveDefinitionNode>): InputObjectTypeDefinitionNode | InputObjectTypeExtensionNode;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
+
import { DirectiveDefinitionNode, InputObjectTypeDefinitionNode, InputObjectTypeExtensionNode } from 'graphql';
|
|
1
2
|
import { Config } from './merge-typedefs.js';
|
|
2
|
-
import { InputObjectTypeDefinitionNode, InputObjectTypeExtensionNode, DirectiveDefinitionNode } from 'graphql';
|
|
3
3
|
export declare function mergeInputType(node: InputObjectTypeDefinitionNode | InputObjectTypeExtensionNode, existingNode: InputObjectTypeDefinitionNode | InputObjectTypeExtensionNode, config?: Config, directives?: Record<string, DirectiveDefinitionNode>): InputObjectTypeDefinitionNode | InputObjectTypeExtensionNode;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { Config } from './merge-typedefs.cjs';
|
|
2
1
|
import { DirectiveDefinitionNode, InterfaceTypeDefinitionNode, InterfaceTypeExtensionNode } from 'graphql';
|
|
2
|
+
import { Config } from './merge-typedefs.cjs';
|
|
3
3
|
export declare function mergeInterface(node: InterfaceTypeDefinitionNode | InterfaceTypeExtensionNode, existingNode: InterfaceTypeDefinitionNode | InterfaceTypeExtensionNode, config?: Config, directives?: Record<string, DirectiveDefinitionNode>): InterfaceTypeDefinitionNode | InterfaceTypeExtensionNode;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { Config } from './merge-typedefs.js';
|
|
2
1
|
import { DirectiveDefinitionNode, InterfaceTypeDefinitionNode, InterfaceTypeExtensionNode } from 'graphql';
|
|
2
|
+
import { Config } from './merge-typedefs.js';
|
|
3
3
|
export declare function mergeInterface(node: InterfaceTypeDefinitionNode | InterfaceTypeExtensionNode, existingNode: InterfaceTypeDefinitionNode | InterfaceTypeExtensionNode, config?: Config, directives?: Record<string, DirectiveDefinitionNode>): InterfaceTypeDefinitionNode | InterfaceTypeExtensionNode;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { Config } from './merge-typedefs.cjs';
|
|
2
1
|
import { DefinitionNode, DirectiveDefinitionNode, SchemaDefinitionNode, SchemaExtensionNode } from 'graphql';
|
|
3
2
|
import { NamedDefinitionNode } from '@graphql-tools/utils';
|
|
3
|
+
import { Config } from './merge-typedefs.cjs';
|
|
4
4
|
export declare const schemaDefSymbol = "SCHEMA_DEF_SYMBOL";
|
|
5
5
|
export type MergedResultMap = Record<string, NamedDefinitionNode> & {
|
|
6
6
|
[schemaDefSymbol]: SchemaDefinitionNode | SchemaExtensionNode;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { Config } from './merge-typedefs.js';
|
|
2
1
|
import { DefinitionNode, DirectiveDefinitionNode, SchemaDefinitionNode, SchemaExtensionNode } from 'graphql';
|
|
3
2
|
import { NamedDefinitionNode } from '@graphql-tools/utils';
|
|
3
|
+
import { Config } from './merge-typedefs.js';
|
|
4
4
|
export declare const schemaDefSymbol = "SCHEMA_DEF_SYMBOL";
|
|
5
5
|
export type MergedResultMap = Record<string, NamedDefinitionNode> & {
|
|
6
6
|
[schemaDefSymbol]: SchemaDefinitionNode | SchemaExtensionNode;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { DefinitionNode, DocumentNode, ParseOptions } from 'graphql';
|
|
2
|
-
import { CompareFn } from './utils.cjs';
|
|
3
2
|
import { GetDocumentNodeFromSchemaOptions, TypeSource } from '@graphql-tools/utils';
|
|
4
3
|
import { OnFieldTypeConflict } from './fields.cjs';
|
|
4
|
+
import { CompareFn } from './utils.cjs';
|
|
5
5
|
type Omit<T, K extends keyof any> = Pick<T, Exclude<keyof T, K>>;
|
|
6
6
|
export interface Config extends ParseOptions, GetDocumentNodeFromSchemaOptions {
|
|
7
7
|
/**
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { DefinitionNode, DocumentNode, ParseOptions } from 'graphql';
|
|
2
|
-
import { CompareFn } from './utils.js';
|
|
3
2
|
import { GetDocumentNodeFromSchemaOptions, TypeSource } from '@graphql-tools/utils';
|
|
4
3
|
import { OnFieldTypeConflict } from './fields.js';
|
|
4
|
+
import { CompareFn } from './utils.js';
|
|
5
5
|
type Omit<T, K extends keyof any> = Pick<T, Exclude<keyof T, K>>;
|
|
6
6
|
export interface Config extends ParseOptions, GetDocumentNodeFromSchemaOptions {
|
|
7
7
|
/**
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { Config } from './merge-typedefs.cjs';
|
|
2
1
|
import { DirectiveDefinitionNode, ObjectTypeDefinitionNode, ObjectTypeExtensionNode } from 'graphql';
|
|
2
|
+
import { Config } from './merge-typedefs.cjs';
|
|
3
3
|
export declare function mergeType(node: ObjectTypeDefinitionNode | ObjectTypeExtensionNode, existingNode: ObjectTypeDefinitionNode | ObjectTypeExtensionNode, config?: Config, directives?: Record<string, DirectiveDefinitionNode>): ObjectTypeDefinitionNode | ObjectTypeExtensionNode;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { Config } from './merge-typedefs.js';
|
|
2
1
|
import { DirectiveDefinitionNode, ObjectTypeDefinitionNode, ObjectTypeExtensionNode } from 'graphql';
|
|
2
|
+
import { Config } from './merge-typedefs.js';
|
|
3
3
|
export declare function mergeType(node: ObjectTypeDefinitionNode | ObjectTypeExtensionNode, existingNode: ObjectTypeDefinitionNode | ObjectTypeExtensionNode, config?: Config, directives?: Record<string, DirectiveDefinitionNode>): ObjectTypeDefinitionNode | ObjectTypeExtensionNode;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ListTypeNode, NamedTypeNode, NonNullTypeNode, Source, TypeNode } from 'graphql';
|
|
2
2
|
export declare function isStringTypes(types: any): types is string;
|
|
3
3
|
export declare function isSourceTypes(types: any): types is Source;
|
|
4
4
|
export declare function extractType(type: TypeNode): NamedTypeNode;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ListTypeNode, NamedTypeNode, NonNullTypeNode, Source, TypeNode } from 'graphql';
|
|
2
2
|
export declare function isStringTypes(types: any): types is string;
|
|
3
3
|
export declare function isSourceTypes(types: any): types is Source;
|
|
4
4
|
export declare function extractType(type: TypeNode): NamedTypeNode;
|