@wundergraph/composition 0.39.1 → 0.40.0
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/dist/errors/errors.d.ts +4 -6
- package/dist/errors/errors.js +19 -33
- package/dist/errors/errors.js.map +1 -1
- package/dist/errors/types.d.ts +16 -0
- package/dist/errors/{utils.js → types.js} +1 -1
- package/dist/errors/types.js.map +1 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/schema-building/types.d.ts +10 -4
- package/dist/schema-building/types.js.map +1 -1
- package/dist/schema-building/utils.d.ts +3 -0
- package/dist/schema-building/utils.js +10 -2
- package/dist/schema-building/utils.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/utils/composition-version.js +1 -1
- package/dist/utils/string-constants.d.ts +5 -1
- package/dist/utils/string-constants.js +18 -4
- package/dist/utils/string-constants.js.map +1 -1
- package/dist/utils/types.d.ts +3 -6
- package/dist/utils/utils.d.ts +2 -4
- package/dist/utils/utils.js +31 -57
- package/dist/utils/utils.js.map +1 -1
- package/dist/v1/federation/federation-factory.d.ts +5 -6
- package/dist/v1/federation/federation-factory.js +97 -79
- package/dist/v1/federation/federation-factory.js.map +1 -1
- package/dist/v1/federation/utils.js +17 -17
- package/dist/v1/federation/utils.js.map +1 -1
- package/dist/v1/federation/walkers.js +2 -2
- package/dist/v1/federation/walkers.js.map +1 -1
- package/dist/v1/normalization/normalization-factory.d.ts +7 -9
- package/dist/v1/normalization/normalization-factory.js +217 -175
- package/dist/v1/normalization/normalization-factory.js.map +1 -1
- package/dist/v1/normalization/types.d.ts +10 -6
- package/dist/v1/normalization/utils.js +8 -8
- package/dist/v1/normalization/utils.js.map +1 -1
- package/dist/v1/normalization/walkers.js +13 -9
- package/dist/v1/normalization/walkers.js.map +1 -1
- package/dist/v1/schema-building/type-merging.d.ts +12 -6
- package/dist/v1/schema-building/type-merging.js +7 -9
- package/dist/v1/schema-building/type-merging.js.map +1 -1
- package/dist/v1/warnings/warnings.js +1 -1
- package/package.json +2 -2
- package/dist/errors/utils.d.ts +0 -4
- package/dist/errors/utils.js.map +0 -1
|
@@ -24,7 +24,6 @@ const integer_constants_1 = require("../utils/integer-constants");
|
|
|
24
24
|
const string_constants_2 = require("../../utils/string-constants");
|
|
25
25
|
const integer_constants_2 = require("../../utils/integer-constants");
|
|
26
26
|
const utils_5 = require("../../utils/utils");
|
|
27
|
-
const index_1 = require("graphql/index");
|
|
28
27
|
const utils_6 = require("../../router-configuration/utils");
|
|
29
28
|
function normalizeSubgraphFromString(subgraphSDL, noLocation = true) {
|
|
30
29
|
const { error, documentNode } = (0, utils_1.safeParse)(subgraphSDL, noLocation);
|
|
@@ -56,6 +55,7 @@ class NormalizationFactory {
|
|
|
56
55
|
fieldSetDataByTypeName = new Map();
|
|
57
56
|
internalGraph;
|
|
58
57
|
invalidConfigureDescriptionNodeDatas = [];
|
|
58
|
+
invalidORScopesCoords = new Set();
|
|
59
59
|
invalidRepeatedDirectiveNameByCoords = new Map();
|
|
60
60
|
isCurrentParentExtension = false;
|
|
61
61
|
isParentObjectExternal = false;
|
|
@@ -73,10 +73,8 @@ class NormalizationFactory {
|
|
|
73
73
|
operationTypeNodeByTypeName = new Map();
|
|
74
74
|
originalParentTypeName = '';
|
|
75
75
|
originalTypeNameByRenamedTypeName = new Map();
|
|
76
|
-
parentDefinitionDataByTypeName = new Map();
|
|
77
|
-
parentsWithChildArguments = new Set();
|
|
78
76
|
overridesByTargetSubgraphName = new Map();
|
|
79
|
-
|
|
77
|
+
parentDefinitionDataByTypeName = new Map();
|
|
80
78
|
schemaData;
|
|
81
79
|
referencedDirectiveNames = new Set();
|
|
82
80
|
referencedTypeNames = new Set();
|
|
@@ -99,42 +97,27 @@ class NormalizationFactory {
|
|
|
99
97
|
operationTypes: new Map(),
|
|
100
98
|
};
|
|
101
99
|
}
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
return { hasUnhandledError: false, typeString: '' };
|
|
109
|
-
}
|
|
110
|
-
switch (parentData.kind) {
|
|
111
|
-
case graphql_1.Kind.ENUM_TYPE_DEFINITION:
|
|
112
|
-
case graphql_1.Kind.INPUT_OBJECT_TYPE_DEFINITION:
|
|
113
|
-
case graphql_1.Kind.SCALAR_TYPE_DEFINITION:
|
|
114
|
-
return { hasUnhandledError: false, typeString: '' };
|
|
115
|
-
default:
|
|
116
|
-
return { hasUnhandledError: true, typeString: (0, utils_5.kindToTypeString)(parentData.kind) };
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
validateArguments(fieldData, fieldPath) {
|
|
120
|
-
const invalidArguments = [];
|
|
121
|
-
for (const [argumentName, argumentNode] of fieldData.argumentDataByArgumentName) {
|
|
122
|
-
const namedTypeName = (0, ast_1.getTypeNodeNamedTypeName)(argumentNode.type);
|
|
123
|
-
if (!constants_1.BASE_SCALARS.has(namedTypeName)) {
|
|
124
|
-
this.referencedTypeNames.add(namedTypeName);
|
|
125
|
-
}
|
|
126
|
-
const { hasUnhandledError, typeString } = this.validateInputNamedType(namedTypeName);
|
|
127
|
-
if (hasUnhandledError) {
|
|
128
|
-
invalidArguments.push({
|
|
129
|
-
argumentName,
|
|
130
|
-
namedType: namedTypeName,
|
|
131
|
-
typeString,
|
|
132
|
-
typeName: (0, merge_1.printTypeNode)(argumentNode.type),
|
|
133
|
-
});
|
|
100
|
+
validateArguments(fieldData, parentKind) {
|
|
101
|
+
for (const argumentData of fieldData.argumentDataByName.values()) {
|
|
102
|
+
const namedTypeName = (0, ast_1.getTypeNodeNamedTypeName)(argumentData.type);
|
|
103
|
+
if (constants_1.BASE_SCALARS.has(namedTypeName)) {
|
|
104
|
+
argumentData.namedTypeKind = graphql_1.Kind.SCALAR_TYPE_DEFINITION;
|
|
105
|
+
continue;
|
|
134
106
|
}
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
107
|
+
const namedTypeData = this.parentDefinitionDataByTypeName.get(namedTypeName);
|
|
108
|
+
if (!namedTypeData) {
|
|
109
|
+
// undefined types are handled elsewhere
|
|
110
|
+
continue;
|
|
111
|
+
}
|
|
112
|
+
if ((0, utils_4.isInputNodeKind)(namedTypeData.kind)) {
|
|
113
|
+
argumentData.namedTypeKind = namedTypeData.kind;
|
|
114
|
+
continue;
|
|
115
|
+
}
|
|
116
|
+
this.errors.push((0, errors_1.invalidNamedTypeError)({
|
|
117
|
+
data: argumentData,
|
|
118
|
+
namedTypeData,
|
|
119
|
+
nodeType: `${(0, utils_5.kindToNodeType)(parentKind)} field argument`,
|
|
120
|
+
}));
|
|
138
121
|
}
|
|
139
122
|
}
|
|
140
123
|
isTypeNameRootType(typeName) {
|
|
@@ -379,13 +362,13 @@ class NormalizationFactory {
|
|
|
379
362
|
return;
|
|
380
363
|
}
|
|
381
364
|
case graphql_1.Kind.FIELD_DEFINITION: {
|
|
382
|
-
for (const [argumentName, argumentData] of data.
|
|
365
|
+
for (const [argumentName, argumentData] of data.argumentDataByName) {
|
|
383
366
|
this.validateDirectives(argumentData, `${data.originalParentTypeName}.${data.name}(${argumentName}: ...)`);
|
|
384
367
|
}
|
|
385
368
|
return;
|
|
386
369
|
}
|
|
387
370
|
case graphql_1.Kind.INPUT_OBJECT_TYPE_DEFINITION: {
|
|
388
|
-
for (const [inputValueName, inputValueData] of data.
|
|
371
|
+
for (const [inputValueName, inputValueData] of data.inputValueDataByName) {
|
|
389
372
|
this.validateDirectives(inputValueData, `${data.name}.${inputValueName}`);
|
|
390
373
|
}
|
|
391
374
|
return;
|
|
@@ -393,7 +376,7 @@ class NormalizationFactory {
|
|
|
393
376
|
case graphql_1.Kind.INTERFACE_TYPE_DEFINITION:
|
|
394
377
|
// intentional fallthrough
|
|
395
378
|
case graphql_1.Kind.OBJECT_TYPE_DEFINITION: {
|
|
396
|
-
for (const [fieldName, fieldData] of data.
|
|
379
|
+
for (const [fieldName, fieldData] of data.fieldDataByName) {
|
|
397
380
|
this.validateDirectives(fieldData, `${data.name}.${fieldName}`);
|
|
398
381
|
}
|
|
399
382
|
return;
|
|
@@ -432,7 +415,7 @@ class NormalizationFactory {
|
|
|
432
415
|
if (incomingExtensionType === types_1.ExtensionType.REAL) {
|
|
433
416
|
return;
|
|
434
417
|
}
|
|
435
|
-
this.errors.push((0, errors_1.duplicateTypeDefinitionError)((0, utils_5.
|
|
418
|
+
this.errors.push((0, errors_1.duplicateTypeDefinitionError)((0, utils_5.kindToNodeType)(parentData.kind), parentData.name));
|
|
436
419
|
return;
|
|
437
420
|
}
|
|
438
421
|
default: {
|
|
@@ -521,37 +504,47 @@ class NormalizationFactory {
|
|
|
521
504
|
this.internalGraph.addEdge(this.internalGraph.addOrUpdateNode(interfaceName, { isAbstract: true }), this.internalGraph.addOrUpdateNode(concreteTypeName), concreteTypeName, true);
|
|
522
505
|
}
|
|
523
506
|
}
|
|
524
|
-
extractArguments(
|
|
507
|
+
extractArguments(argumentDataByName, node) {
|
|
525
508
|
if (!node.arguments?.length) {
|
|
526
|
-
return
|
|
509
|
+
return argumentDataByName;
|
|
527
510
|
}
|
|
528
511
|
const fieldName = node.name.value;
|
|
529
512
|
const originalFieldPath = `${this.originalParentTypeName}.${fieldName}`;
|
|
530
|
-
const renamedFieldPath = `${this.renamedParentTypeName}.${fieldName}`;
|
|
531
|
-
this.parentsWithChildArguments.add(this.originalParentTypeName);
|
|
532
513
|
const duplicatedArguments = new Set();
|
|
533
514
|
for (const argumentNode of node.arguments) {
|
|
534
515
|
const argumentName = argumentNode.name.value;
|
|
535
|
-
if (
|
|
516
|
+
if (argumentDataByName.has(argumentName)) {
|
|
536
517
|
duplicatedArguments.add(argumentName);
|
|
537
518
|
continue;
|
|
538
519
|
}
|
|
539
|
-
this.addInputValueDataByNode(
|
|
520
|
+
this.addInputValueDataByNode({
|
|
521
|
+
fieldName,
|
|
522
|
+
inputValueDataByName: argumentDataByName,
|
|
523
|
+
isArgument: true,
|
|
524
|
+
node: argumentNode,
|
|
525
|
+
originalParentTypeName: this.originalParentTypeName,
|
|
526
|
+
renamedParentTypeName: this.renamedParentTypeName,
|
|
527
|
+
});
|
|
540
528
|
}
|
|
541
529
|
if (duplicatedArguments.size > 0) {
|
|
542
530
|
this.errors.push((0, errors_1.duplicateArgumentsError)(originalFieldPath, [...duplicatedArguments]));
|
|
543
531
|
}
|
|
544
|
-
return
|
|
532
|
+
return argumentDataByName;
|
|
545
533
|
}
|
|
546
534
|
addPersistedDirectiveDefinitionDataByNode(persistedDirectiveDefinitionDataByDirectiveName, node, executableLocations) {
|
|
547
535
|
const name = node.name.value;
|
|
548
|
-
const
|
|
536
|
+
const directiveName = `@${name}`;
|
|
537
|
+
const argumentDataByName = new Map();
|
|
549
538
|
for (const argumentNode of node.arguments || []) {
|
|
550
|
-
|
|
551
|
-
|
|
539
|
+
this.addInputValueDataByNode({
|
|
540
|
+
inputValueDataByName: argumentDataByName,
|
|
541
|
+
isArgument: true,
|
|
542
|
+
node: argumentNode,
|
|
543
|
+
originalParentTypeName: directiveName,
|
|
544
|
+
});
|
|
552
545
|
}
|
|
553
546
|
persistedDirectiveDefinitionDataByDirectiveName.set(name, {
|
|
554
|
-
argumentDataByArgumentName,
|
|
547
|
+
argumentDataByArgumentName: argumentDataByName,
|
|
555
548
|
executableLocations,
|
|
556
549
|
name,
|
|
557
550
|
repeatable: node.repeatable,
|
|
@@ -655,8 +648,9 @@ class NormalizationFactory {
|
|
|
655
648
|
const parentTypeName = this.renamedParentTypeName || this.originalParentTypeName;
|
|
656
649
|
const fieldCoords = `${this.originalParentTypeName}.${name}`;
|
|
657
650
|
const { isExternal, isShareable } = (0, utils_4.isNodeExternalOrShareable)(node, !this.isSubgraphVersionTwo, directivesByDirectiveName);
|
|
651
|
+
const namedTypeName = (0, ast_1.getTypeNodeNamedTypeName)(node.type);
|
|
658
652
|
const fieldData = {
|
|
659
|
-
|
|
653
|
+
argumentDataByName: argumentDataByArgumentName,
|
|
660
654
|
configureDescriptionDataBySubgraphName: new Map(),
|
|
661
655
|
externalFieldDataBySubgraphName: new Map([
|
|
662
656
|
[this.subgraphName, (0, utils_4.newExternalFieldData)(isExternal)],
|
|
@@ -666,7 +660,8 @@ class NormalizationFactory {
|
|
|
666
660
|
isShareableBySubgraphName: new Map([[this.subgraphName, isShareable]]),
|
|
667
661
|
kind: graphql_1.Kind.FIELD_DEFINITION,
|
|
668
662
|
name,
|
|
669
|
-
|
|
663
|
+
namedTypeKind: constants_1.BASE_SCALARS.has(namedTypeName) ? graphql_1.Kind.SCALAR_TYPE_DEFINITION : graphql_1.Kind.NULL,
|
|
664
|
+
namedTypeName,
|
|
670
665
|
node: (0, ast_1.getMutableFieldNode)(node, fieldCoords, this.errors),
|
|
671
666
|
originalParentTypeName: this.originalParentTypeName,
|
|
672
667
|
persistedDirectivesData: (0, utils_4.newPersistedDirectivesData)(),
|
|
@@ -683,33 +678,44 @@ class NormalizationFactory {
|
|
|
683
678
|
fieldDataByFieldName.set(name, fieldData);
|
|
684
679
|
return fieldData;
|
|
685
680
|
}
|
|
686
|
-
addInputValueDataByNode(
|
|
681
|
+
addInputValueDataByNode({ fieldName, inputValueDataByName, isArgument, node, originalParentTypeName, renamedParentTypeName, }) {
|
|
682
|
+
const federatedParentTypeName = renamedParentTypeName || originalParentTypeName;
|
|
687
683
|
const name = node.name.value;
|
|
688
|
-
//
|
|
689
|
-
const
|
|
684
|
+
// directives do not have field names
|
|
685
|
+
const originalCoords = isArgument
|
|
686
|
+
? `${originalParentTypeName}${fieldName ? `.${fieldName}` : ''}(${name}: ...)`
|
|
687
|
+
: `${originalParentTypeName}.${name}`;
|
|
690
688
|
if (node.defaultValue && !(0, utils_4.areDefaultValuesCompatible)(node.type, node.defaultValue)) {
|
|
691
|
-
this.errors.push((0, errors_1.incompatibleInputValueDefaultValueTypeError)((isArgument ? string_constants_2.ARGUMENT : string_constants_2.INPUT_FIELD) + ` "${name}"`,
|
|
689
|
+
this.errors.push((0, errors_1.incompatibleInputValueDefaultValueTypeError)((isArgument ? string_constants_2.ARGUMENT : string_constants_2.INPUT_FIELD) + ` "${name}"`, originalCoords, (0, merge_1.printTypeNode)(node.type), (0, graphql_1.print)(node.defaultValue)));
|
|
692
690
|
}
|
|
691
|
+
const federatedCoords = isArgument
|
|
692
|
+
? `${federatedParentTypeName}${fieldName ? `.${fieldName}` : ''}(${name}: ...)`
|
|
693
|
+
: `${federatedParentTypeName}.${name}`;
|
|
694
|
+
const namedTypeName = (0, ast_1.getTypeNodeNamedTypeName)(node.type);
|
|
693
695
|
const inputValueData = {
|
|
694
696
|
configureDescriptionDataBySubgraphName: new Map(),
|
|
695
697
|
directivesByDirectiveName: this.extractDirectives(node, new Map()),
|
|
698
|
+
federatedCoords,
|
|
699
|
+
fieldName,
|
|
696
700
|
includeDefaultValue: !!node.defaultValue,
|
|
697
701
|
isArgument,
|
|
698
702
|
kind: isArgument ? graphql_1.Kind.ARGUMENT : graphql_1.Kind.INPUT_VALUE_DEFINITION,
|
|
699
703
|
name,
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
704
|
+
namedTypeKind: constants_1.BASE_SCALARS.has(namedTypeName) ? graphql_1.Kind.SCALAR_TYPE_DEFINITION : graphql_1.Kind.NULL,
|
|
705
|
+
namedTypeName,
|
|
706
|
+
node: (0, ast_1.getMutableInputValueNode)(node, originalParentTypeName, this.errors),
|
|
707
|
+
originalCoords,
|
|
708
|
+
originalParentTypeName: originalParentTypeName,
|
|
703
709
|
persistedDirectivesData: (0, utils_4.newPersistedDirectivesData)(),
|
|
704
|
-
|
|
710
|
+
renamedParentTypeName: federatedParentTypeName,
|
|
705
711
|
requiredSubgraphNames: new Set((0, utils_4.isTypeRequired)(node.type) ? [this.subgraphName] : []),
|
|
706
712
|
subgraphNames: new Set([this.subgraphName]),
|
|
707
|
-
type: (0, ast_1.getMutableTypeNode)(node.type,
|
|
713
|
+
type: (0, ast_1.getMutableTypeNode)(node.type, originalParentTypeName, this.errors),
|
|
708
714
|
defaultValue: node.defaultValue, // TODO validate
|
|
709
715
|
description: (0, utils_1.formatDescription)(node.description),
|
|
710
716
|
};
|
|
711
717
|
this.extractConfigureDescriptionsData(inputValueData);
|
|
712
|
-
|
|
718
|
+
inputValueDataByName.set(name, inputValueData);
|
|
713
719
|
}
|
|
714
720
|
upsertInterfaceDataByNode(node, isRealExtension = false) {
|
|
715
721
|
const typeName = node.name.value;
|
|
@@ -724,7 +730,7 @@ class NormalizationFactory {
|
|
|
724
730
|
}
|
|
725
731
|
if (parentData) {
|
|
726
732
|
if (parentData.kind !== graphql_1.Kind.INTERFACE_TYPE_DEFINITION) {
|
|
727
|
-
this.errors.push((0, errors_1.multipleNamedTypeDefinitionError)(typeName, (0, utils_5.
|
|
733
|
+
this.errors.push((0, errors_1.multipleNamedTypeDefinitionError)(typeName, (0, utils_5.kindToNodeType)(parentData.kind), (0, utils_3.kindToConvertedTypeString)(node.kind)));
|
|
728
734
|
return;
|
|
729
735
|
}
|
|
730
736
|
this.updateCompositeOutputDataByNode(node, parentData, extensionType);
|
|
@@ -734,7 +740,7 @@ class NormalizationFactory {
|
|
|
734
740
|
configureDescriptionDataBySubgraphName: new Map(),
|
|
735
741
|
directivesByDirectiveName,
|
|
736
742
|
extensionType,
|
|
737
|
-
|
|
743
|
+
fieldDataByName: new Map(),
|
|
738
744
|
implementedInterfaceTypeNames: this.extractImplementedInterfaceTypeNames(node, new Set()),
|
|
739
745
|
isEntity: directivesByDirectiveName.has(string_constants_2.KEY),
|
|
740
746
|
isInaccessible: directivesByDirectiveName.has(string_constants_2.INACCESSIBLE),
|
|
@@ -781,7 +787,7 @@ class NormalizationFactory {
|
|
|
781
787
|
this.addInterfaceObjectFieldsByNode(node);
|
|
782
788
|
if (parentData) {
|
|
783
789
|
if (parentData.kind !== graphql_1.Kind.OBJECT_TYPE_DEFINITION) {
|
|
784
|
-
this.errors.push((0, errors_1.multipleNamedTypeDefinitionError)(typeName, (0, utils_5.
|
|
790
|
+
this.errors.push((0, errors_1.multipleNamedTypeDefinitionError)(typeName, (0, utils_5.kindToNodeType)(parentData.kind), (0, utils_3.kindToConvertedTypeString)(node.kind)));
|
|
785
791
|
return;
|
|
786
792
|
}
|
|
787
793
|
this.updateCompositeOutputDataByNode(node, parentData, extensionType);
|
|
@@ -794,7 +800,7 @@ class NormalizationFactory {
|
|
|
794
800
|
configureDescriptionDataBySubgraphName: new Map(),
|
|
795
801
|
directivesByDirectiveName,
|
|
796
802
|
extensionType,
|
|
797
|
-
|
|
803
|
+
fieldDataByName: new Map(),
|
|
798
804
|
implementedInterfaceTypeNames,
|
|
799
805
|
isEntity: directivesByDirectiveName.has(string_constants_2.KEY),
|
|
800
806
|
isInaccessible: directivesByDirectiveName.has(string_constants_2.INACCESSIBLE),
|
|
@@ -818,7 +824,7 @@ class NormalizationFactory {
|
|
|
818
824
|
const extensionType = this.getNodeExtensionType(isRealExtension, directivesByDirectiveName);
|
|
819
825
|
if (parentData) {
|
|
820
826
|
if (parentData.kind !== graphql_1.Kind.ENUM_TYPE_DEFINITION) {
|
|
821
|
-
this.errors.push((0, errors_1.multipleNamedTypeDefinitionError)(typeName, (0, utils_5.
|
|
827
|
+
this.errors.push((0, errors_1.multipleNamedTypeDefinitionError)(typeName, (0, utils_5.kindToNodeType)(parentData.kind), (0, utils_3.kindToConvertedTypeString)(node.kind)));
|
|
822
828
|
return;
|
|
823
829
|
}
|
|
824
830
|
this.setParentDataExtensionType(parentData, extensionType);
|
|
@@ -852,7 +858,7 @@ class NormalizationFactory {
|
|
|
852
858
|
const extensionType = this.getNodeExtensionType(isRealExtension, directivesByDirectiveName);
|
|
853
859
|
if (parentData) {
|
|
854
860
|
if (parentData.kind !== graphql_1.Kind.INPUT_OBJECT_TYPE_DEFINITION) {
|
|
855
|
-
this.errors.push((0, errors_1.multipleNamedTypeDefinitionError)(typeName, (0, utils_5.
|
|
861
|
+
this.errors.push((0, errors_1.multipleNamedTypeDefinitionError)(typeName, (0, utils_5.kindToNodeType)(parentData.kind), (0, utils_3.kindToConvertedTypeString)(node.kind)));
|
|
856
862
|
return;
|
|
857
863
|
}
|
|
858
864
|
this.setParentDataExtensionType(parentData, extensionType);
|
|
@@ -866,7 +872,7 @@ class NormalizationFactory {
|
|
|
866
872
|
configureDescriptionDataBySubgraphName: new Map(),
|
|
867
873
|
directivesByDirectiveName,
|
|
868
874
|
extensionType,
|
|
869
|
-
|
|
875
|
+
inputValueDataByName: new Map(),
|
|
870
876
|
isInaccessible: directivesByDirectiveName.has(string_constants_2.INACCESSIBLE),
|
|
871
877
|
kind: graphql_1.Kind.INPUT_OBJECT_TYPE_DEFINITION,
|
|
872
878
|
name: typeName,
|
|
@@ -886,7 +892,7 @@ class NormalizationFactory {
|
|
|
886
892
|
const extensionType = this.getNodeExtensionType(isRealExtension, directivesByDirectiveName);
|
|
887
893
|
if (parentData) {
|
|
888
894
|
if (parentData.kind !== graphql_1.Kind.SCALAR_TYPE_DEFINITION) {
|
|
889
|
-
this.errors.push((0, errors_1.multipleNamedTypeDefinitionError)(typeName, (0, utils_5.
|
|
895
|
+
this.errors.push((0, errors_1.multipleNamedTypeDefinitionError)(typeName, (0, utils_5.kindToNodeType)(parentData.kind), (0, utils_3.kindToConvertedTypeString)(node.kind)));
|
|
890
896
|
return;
|
|
891
897
|
}
|
|
892
898
|
this.setParentDataExtensionType(parentData, extensionType);
|
|
@@ -943,7 +949,7 @@ class NormalizationFactory {
|
|
|
943
949
|
this.addConcreteTypeNamesForUnion(node);
|
|
944
950
|
if (parentData) {
|
|
945
951
|
if (parentData.kind !== graphql_1.Kind.UNION_TYPE_DEFINITION) {
|
|
946
|
-
this.errors.push((0, errors_1.multipleNamedTypeDefinitionError)(typeName, (0, utils_5.
|
|
952
|
+
this.errors.push((0, errors_1.multipleNamedTypeDefinitionError)(typeName, (0, utils_5.kindToNodeType)(parentData.kind), (0, utils_3.kindToConvertedTypeString)(node.kind)));
|
|
947
953
|
return;
|
|
948
954
|
}
|
|
949
955
|
this.setParentDataExtensionType(parentData, extensionType);
|
|
@@ -1034,7 +1040,7 @@ class NormalizationFactory {
|
|
|
1034
1040
|
if (!isProvides) {
|
|
1035
1041
|
return { fieldSetParentData: parentData };
|
|
1036
1042
|
}
|
|
1037
|
-
const fieldData = (0, utils_5.getOrThrowError)(parentData.
|
|
1043
|
+
const fieldData = (0, utils_5.getOrThrowError)(parentData.fieldDataByName, fieldName, `${parentTypeName}.fieldDataByFieldName`);
|
|
1038
1044
|
const fieldNamedTypeName = (0, ast_1.getTypeNodeNamedTypeName)(fieldData.node.type);
|
|
1039
1045
|
const namedTypeData = this.parentDefinitionDataByTypeName.get(fieldNamedTypeName);
|
|
1040
1046
|
// This error should never happen
|
|
@@ -1069,7 +1075,7 @@ class NormalizationFactory {
|
|
|
1069
1075
|
let shouldDefineSelectionSet = true;
|
|
1070
1076
|
let lastFieldName = directiveFieldName;
|
|
1071
1077
|
let hasConditionalField = false;
|
|
1072
|
-
(0,
|
|
1078
|
+
(0, graphql_1.visit)(documentNode, {
|
|
1073
1079
|
Argument: {
|
|
1074
1080
|
enter() {
|
|
1075
1081
|
return false;
|
|
@@ -1081,28 +1087,28 @@ class NormalizationFactory {
|
|
|
1081
1087
|
const parentTypeName = parentData.name;
|
|
1082
1088
|
if (parentData.kind === graphql_1.Kind.UNION_TYPE_DEFINITION) {
|
|
1083
1089
|
errorMessages.push((0, errors_1.invalidSelectionOnUnionErrorMessage)(fieldSet, fieldCoordsPath, parentTypeName));
|
|
1084
|
-
return
|
|
1090
|
+
return graphql_1.BREAK;
|
|
1085
1091
|
}
|
|
1086
1092
|
const fieldName = node.name.value;
|
|
1087
1093
|
const currentFieldCoords = `${parentTypeName}.${fieldName}`;
|
|
1088
1094
|
nf.unvalidatedExternalFieldCoords.delete(currentFieldCoords);
|
|
1089
1095
|
// If an object-like was just visited, a selection set should have been entered
|
|
1090
1096
|
if (shouldDefineSelectionSet) {
|
|
1091
|
-
errorMessages.push((0, errors_1.invalidSelectionSetErrorMessage)(fieldSet, fieldCoordsPath, parentTypeName, (0, utils_5.
|
|
1092
|
-
return
|
|
1097
|
+
errorMessages.push((0, errors_1.invalidSelectionSetErrorMessage)(fieldSet, fieldCoordsPath, parentTypeName, (0, utils_5.kindToNodeType)(parentData.kind)));
|
|
1098
|
+
return graphql_1.BREAK;
|
|
1093
1099
|
}
|
|
1094
1100
|
fieldCoordsPath.push(currentFieldCoords);
|
|
1095
1101
|
fieldPath.push(fieldName);
|
|
1096
1102
|
lastFieldName = fieldName;
|
|
1097
|
-
const fieldData = parentData.
|
|
1103
|
+
const fieldData = parentData.fieldDataByName.get(fieldName);
|
|
1098
1104
|
// undefined if the field does not exist on the parent
|
|
1099
1105
|
if (!fieldData) {
|
|
1100
1106
|
errorMessages.push((0, errors_1.undefinedFieldInFieldSetErrorMessage)(fieldSet, parentTypeName, fieldName));
|
|
1101
|
-
return
|
|
1107
|
+
return graphql_1.BREAK;
|
|
1102
1108
|
}
|
|
1103
1109
|
if (definedFields[currentDepth].has(fieldName)) {
|
|
1104
1110
|
errorMessages.push((0, errors_1.duplicateFieldInFieldSetErrorMessage)(fieldSet, currentFieldCoords));
|
|
1105
|
-
return
|
|
1111
|
+
return graphql_1.BREAK;
|
|
1106
1112
|
}
|
|
1107
1113
|
definedFields[currentDepth].add(fieldName);
|
|
1108
1114
|
const { isDefinedExternal, isUnconditionallyProvided } = (0, utils_5.getOrThrowError)(fieldData.externalFieldDataBySubgraphName, nf.subgraphName, `${currentFieldCoords}.externalFieldDataBySubgraphName`);
|
|
@@ -1156,7 +1162,7 @@ class NormalizationFactory {
|
|
|
1156
1162
|
if (!namedTypeData) {
|
|
1157
1163
|
// Should not be possible to receive this error
|
|
1158
1164
|
errorMessages.push((0, errors_1.unknownTypeInFieldSetErrorMessage)(fieldSet, currentFieldCoords, namedTypeName));
|
|
1159
|
-
return
|
|
1165
|
+
return graphql_1.BREAK;
|
|
1160
1166
|
}
|
|
1161
1167
|
// TODO isFieldConditional
|
|
1162
1168
|
if (isDefinedExternal) {
|
|
@@ -1188,7 +1194,7 @@ class NormalizationFactory {
|
|
|
1188
1194
|
const fieldCoordinates = fieldCoordsPath.length < 1 ? selectionSetParentData.name : fieldCoordsPath[fieldCoordsPath.length - 1];
|
|
1189
1195
|
if (!node.typeCondition) {
|
|
1190
1196
|
errorMessages.push((0, errors_1.inlineFragmentWithoutTypeConditionErrorMessage)(fieldSet, fieldCoordinates));
|
|
1191
|
-
return
|
|
1197
|
+
return graphql_1.BREAK;
|
|
1192
1198
|
}
|
|
1193
1199
|
const typeConditionName = node.typeCondition.name.value;
|
|
1194
1200
|
// It's possible to infinitely define fragments
|
|
@@ -1199,12 +1205,12 @@ class NormalizationFactory {
|
|
|
1199
1205
|
}
|
|
1200
1206
|
if (!(0, utils_1.isKindAbstract)(parentData.kind)) {
|
|
1201
1207
|
errorMessages.push((0, errors_1.invalidInlineFragmentTypeErrorMessage)(fieldSet, fieldCoordsPath, typeConditionName, parentTypeName));
|
|
1202
|
-
return
|
|
1208
|
+
return graphql_1.BREAK;
|
|
1203
1209
|
}
|
|
1204
1210
|
const fragmentNamedTypeData = nf.parentDefinitionDataByTypeName.get(typeConditionName);
|
|
1205
1211
|
if (!fragmentNamedTypeData) {
|
|
1206
1212
|
errorMessages.push((0, errors_1.unknownInlineFragmentTypeConditionErrorMessage)(fieldSet, fieldCoordsPath, parentTypeName, typeConditionName));
|
|
1207
|
-
return
|
|
1213
|
+
return graphql_1.BREAK;
|
|
1208
1214
|
}
|
|
1209
1215
|
shouldDefineSelectionSet = true;
|
|
1210
1216
|
switch (fragmentNamedTypeData.kind) {
|
|
@@ -1228,12 +1234,12 @@ class NormalizationFactory {
|
|
|
1228
1234
|
return;
|
|
1229
1235
|
}
|
|
1230
1236
|
default: {
|
|
1231
|
-
errorMessages.push((0, errors_1.invalidInlineFragmentTypeConditionTypeErrorMessage)(fieldSet, fieldCoordsPath, parentTypeName, typeConditionName, (0, utils_5.
|
|
1232
|
-
return
|
|
1237
|
+
errorMessages.push((0, errors_1.invalidInlineFragmentTypeConditionTypeErrorMessage)(fieldSet, fieldCoordsPath, parentTypeName, typeConditionName, (0, utils_5.kindToNodeType)(fragmentNamedTypeData.kind)));
|
|
1238
|
+
return graphql_1.BREAK;
|
|
1233
1239
|
}
|
|
1234
1240
|
}
|
|
1235
|
-
errorMessages.push((0, errors_1.invalidInlineFragmentTypeConditionErrorMessage)(fieldSet, fieldCoordsPath, typeConditionName, (0, utils_5.
|
|
1236
|
-
return
|
|
1241
|
+
errorMessages.push((0, errors_1.invalidInlineFragmentTypeConditionErrorMessage)(fieldSet, fieldCoordsPath, typeConditionName, (0, utils_5.kindToNodeType)(parentData.kind), parentTypeName));
|
|
1242
|
+
return graphql_1.BREAK;
|
|
1237
1243
|
},
|
|
1238
1244
|
},
|
|
1239
1245
|
SelectionSet: {
|
|
@@ -1243,32 +1249,32 @@ class NormalizationFactory {
|
|
|
1243
1249
|
if (parentData.kind === graphql_1.Kind.UNION_TYPE_DEFINITION) {
|
|
1244
1250
|
// Should never happen
|
|
1245
1251
|
errorMessages.push((0, errors_1.unparsableFieldSetSelectionErrorMessage)(fieldSet, lastFieldName));
|
|
1246
|
-
return
|
|
1252
|
+
return graphql_1.BREAK;
|
|
1247
1253
|
}
|
|
1248
|
-
const fieldData = parentData.
|
|
1254
|
+
const fieldData = parentData.fieldDataByName.get(lastFieldName);
|
|
1249
1255
|
if (!fieldData) {
|
|
1250
1256
|
errorMessages.push((0, errors_1.undefinedFieldInFieldSetErrorMessage)(fieldSet, parentData.name, lastFieldName));
|
|
1251
|
-
return
|
|
1257
|
+
return graphql_1.BREAK;
|
|
1252
1258
|
}
|
|
1253
1259
|
const fieldNamedTypeName = (0, ast_1.getTypeNodeNamedTypeName)(fieldData.node.type);
|
|
1254
1260
|
// If the child is not found, it's a base scalar. Undefined types would have already been handled.
|
|
1255
1261
|
const namedTypeData = nf.parentDefinitionDataByTypeName.get(fieldNamedTypeName);
|
|
1256
1262
|
const childKind = namedTypeData ? namedTypeData.kind : graphql_1.Kind.SCALAR_TYPE_DEFINITION;
|
|
1257
|
-
errorMessages.push((0, errors_1.invalidSelectionSetDefinitionErrorMessage)(fieldSet, fieldCoordsPath, fieldNamedTypeName, (0, utils_5.
|
|
1258
|
-
return
|
|
1263
|
+
errorMessages.push((0, errors_1.invalidSelectionSetDefinitionErrorMessage)(fieldSet, fieldCoordsPath, fieldNamedTypeName, (0, utils_5.kindToNodeType)(childKind)));
|
|
1264
|
+
return graphql_1.BREAK;
|
|
1259
1265
|
}
|
|
1260
1266
|
currentDepth += 1;
|
|
1261
1267
|
shouldDefineSelectionSet = false;
|
|
1262
1268
|
if (currentDepth < 0 || currentDepth >= parentDatas.length) {
|
|
1263
1269
|
errorMessages.push((0, errors_1.unparsableFieldSetSelectionErrorMessage)(fieldSet, lastFieldName));
|
|
1264
|
-
return
|
|
1270
|
+
return graphql_1.BREAK;
|
|
1265
1271
|
}
|
|
1266
1272
|
definedFields.push(new Set());
|
|
1267
1273
|
},
|
|
1268
1274
|
leave() {
|
|
1269
1275
|
if (shouldDefineSelectionSet) {
|
|
1270
1276
|
const parentData = parentDatas[currentDepth + 1];
|
|
1271
|
-
errorMessages.push((0, errors_1.invalidSelectionSetErrorMessage)(fieldSet, fieldCoordsPath, parentData.name, (0, utils_5.
|
|
1277
|
+
errorMessages.push((0, errors_1.invalidSelectionSetErrorMessage)(fieldSet, fieldCoordsPath, parentData.name, (0, utils_5.kindToNodeType)(parentData.kind)));
|
|
1272
1278
|
shouldDefineSelectionSet = false;
|
|
1273
1279
|
}
|
|
1274
1280
|
// Empty selection sets would be a parse error, so it is unnecessary to handle them
|
|
@@ -1348,7 +1354,7 @@ class NormalizationFactory {
|
|
|
1348
1354
|
continue;
|
|
1349
1355
|
}
|
|
1350
1356
|
if (interfaceData.kind !== graphql_1.Kind.INTERFACE_TYPE_DEFINITION) {
|
|
1351
|
-
invalidImplementationTypeStringByTypeName.set(interfaceData.name, (0, utils_5.
|
|
1357
|
+
invalidImplementationTypeStringByTypeName.set(interfaceData.name, (0, utils_5.kindToNodeType)(interfaceData.kind));
|
|
1352
1358
|
continue;
|
|
1353
1359
|
}
|
|
1354
1360
|
if (data.name === interfaceData.name) {
|
|
@@ -1360,10 +1366,10 @@ class NormalizationFactory {
|
|
|
1360
1366
|
unimplementedFields: [],
|
|
1361
1367
|
};
|
|
1362
1368
|
let hasErrors = false;
|
|
1363
|
-
for (const [fieldName, interfaceField] of interfaceData.
|
|
1369
|
+
for (const [fieldName, interfaceField] of interfaceData.fieldDataByName) {
|
|
1364
1370
|
this.unvalidatedExternalFieldCoords.delete(`${data.name}.${fieldName}`);
|
|
1365
1371
|
let hasNestedErrors = false;
|
|
1366
|
-
const fieldData = data.
|
|
1372
|
+
const fieldData = data.fieldDataByName.get(fieldName);
|
|
1367
1373
|
if (!fieldData) {
|
|
1368
1374
|
hasErrors = true;
|
|
1369
1375
|
implementationErrors.unimplementedFields.push(fieldName);
|
|
@@ -1383,9 +1389,9 @@ class NormalizationFactory {
|
|
|
1383
1389
|
invalidFieldImplementation.implementedResponseType = (0, merge_1.printTypeNode)(fieldData.node.type);
|
|
1384
1390
|
}
|
|
1385
1391
|
const handledArguments = new Set();
|
|
1386
|
-
for (const [argumentName, interfaceArgument] of interfaceField.
|
|
1392
|
+
for (const [argumentName, interfaceArgument] of interfaceField.argumentDataByName) {
|
|
1387
1393
|
handledArguments.add(argumentName);
|
|
1388
|
-
const containerArgument = fieldData.
|
|
1394
|
+
const containerArgument = fieldData.argumentDataByName.get(argumentName);
|
|
1389
1395
|
// The type implementing the interface must include all arguments with no variation for that argument
|
|
1390
1396
|
if (!containerArgument) {
|
|
1391
1397
|
hasErrors = true;
|
|
@@ -1403,7 +1409,7 @@ class NormalizationFactory {
|
|
|
1403
1409
|
}
|
|
1404
1410
|
}
|
|
1405
1411
|
// Additional arguments must be optional (nullable)
|
|
1406
|
-
for (const [argumentName, argumentData] of fieldData.
|
|
1412
|
+
for (const [argumentName, argumentData] of fieldData.argumentDataByName) {
|
|
1407
1413
|
if (handledArguments.has(argumentName)) {
|
|
1408
1414
|
continue;
|
|
1409
1415
|
}
|
|
@@ -1434,7 +1440,7 @@ class NormalizationFactory {
|
|
|
1434
1440
|
this.errors.push((0, errors_1.selfImplementationError)(data.name));
|
|
1435
1441
|
}
|
|
1436
1442
|
if (implementationErrorsMap.size > 0) {
|
|
1437
|
-
this.errors.push((0, errors_1.invalidInterfaceImplementationError)(data.name, (0, utils_5.
|
|
1443
|
+
this.errors.push((0, errors_1.invalidInterfaceImplementationError)(data.name, (0, utils_5.kindToNodeType)(data.kind), implementationErrorsMap));
|
|
1438
1444
|
}
|
|
1439
1445
|
}
|
|
1440
1446
|
handleAuthenticatedDirective(data, parentTypeName) {
|
|
@@ -1797,7 +1803,7 @@ class NormalizationFactory {
|
|
|
1797
1803
|
return;
|
|
1798
1804
|
}
|
|
1799
1805
|
const validEventDirectiveNames = this.getValidEventsDirectiveNamesForOperationTypeNode(operationTypeNode);
|
|
1800
|
-
for (const [fieldName, fieldData] of data.
|
|
1806
|
+
for (const [fieldName, fieldData] of data.fieldDataByName) {
|
|
1801
1807
|
const fieldCoords = `${fieldData.originalParentTypeName}.${fieldName}`;
|
|
1802
1808
|
const definedEventsDirectiveNames = new Set();
|
|
1803
1809
|
for (const eventsDirectiveName of string_constants_1.EVENT_DIRECTIVE_NAMES) {
|
|
@@ -1872,11 +1878,11 @@ class NormalizationFactory {
|
|
|
1872
1878
|
if (data.kind !== graphql_1.Kind.OBJECT_TYPE_DEFINITION) {
|
|
1873
1879
|
return false;
|
|
1874
1880
|
}
|
|
1875
|
-
if (data.
|
|
1881
|
+
if (data.fieldDataByName.size != 1) {
|
|
1876
1882
|
return false;
|
|
1877
1883
|
}
|
|
1878
|
-
for (const [fieldName, fieldData] of data.
|
|
1879
|
-
if (fieldData.
|
|
1884
|
+
for (const [fieldName, fieldData] of data.fieldDataByName) {
|
|
1885
|
+
if (fieldData.argumentDataByName.size > 0) {
|
|
1880
1886
|
return false;
|
|
1881
1887
|
}
|
|
1882
1888
|
if (fieldName !== string_constants_2.SUCCESS) {
|
|
@@ -1892,10 +1898,10 @@ class NormalizationFactory {
|
|
|
1892
1898
|
if (streamConfigurationInputData.kind !== graphql_1.Kind.INPUT_OBJECT_TYPE_DEFINITION) {
|
|
1893
1899
|
return false;
|
|
1894
1900
|
}
|
|
1895
|
-
if (streamConfigurationInputData.
|
|
1901
|
+
if (streamConfigurationInputData.inputValueDataByName.size != 3) {
|
|
1896
1902
|
return false;
|
|
1897
1903
|
}
|
|
1898
|
-
for (const [inputValueName, inputValueData] of streamConfigurationInputData.
|
|
1904
|
+
for (const [inputValueName, inputValueData] of streamConfigurationInputData.inputValueDataByName) {
|
|
1899
1905
|
switch (inputValueName) {
|
|
1900
1906
|
case string_constants_2.CONSUMER_INACTIVE_THRESHOLD: {
|
|
1901
1907
|
if ((0, merge_1.printTypeNode)(inputValueData.type) !== string_constants_2.NON_NULLABLE_INT) {
|
|
@@ -1951,7 +1957,7 @@ class NormalizationFactory {
|
|
|
1951
1957
|
continue;
|
|
1952
1958
|
}
|
|
1953
1959
|
this.validateEventDrivenKeyDefinition(typeName, invalidKeyFieldSetsByEntityTypeName);
|
|
1954
|
-
this.validateEventDrivenObjectFields(data.
|
|
1960
|
+
this.validateEventDrivenObjectFields(data.fieldDataByName, keyFieldNames, nonExternalKeyFieldNameByFieldPath, nonKeyFieldNameByFieldPath);
|
|
1955
1961
|
}
|
|
1956
1962
|
if (!this.isEdfsPublishResultValid()) {
|
|
1957
1963
|
errorMessages.push(errors_1.invalidEdfsPublishResultObjectErrorMessage);
|
|
@@ -2013,7 +2019,7 @@ class NormalizationFactory {
|
|
|
2013
2019
|
continue;
|
|
2014
2020
|
}
|
|
2015
2021
|
if (memberData.kind !== graphql_1.Kind.OBJECT_TYPE_DEFINITION) {
|
|
2016
|
-
invalidMembers.push(`"${memberName}", which is type "${(0, utils_5.
|
|
2022
|
+
invalidMembers.push(`"${memberName}", which is type "${(0, utils_5.kindToNodeType)(memberData.kind)}"`);
|
|
2017
2023
|
}
|
|
2018
2024
|
}
|
|
2019
2025
|
if (invalidMembers.length > 0) {
|
|
@@ -2097,13 +2103,13 @@ class NormalizationFactory {
|
|
|
2097
2103
|
getInputObjectNodeByData(inputObjectDefinitionData) {
|
|
2098
2104
|
inputObjectDefinitionData.node.description = inputObjectDefinitionData.description;
|
|
2099
2105
|
inputObjectDefinitionData.node.directives = this.getValidFlattenedDirectiveArray(inputObjectDefinitionData.directivesByDirectiveName, inputObjectDefinitionData.name);
|
|
2100
|
-
inputObjectDefinitionData.node.fields = (0, utils_4.childMapToValueArray)(inputObjectDefinitionData.
|
|
2106
|
+
inputObjectDefinitionData.node.fields = (0, utils_4.childMapToValueArray)(inputObjectDefinitionData.inputValueDataByName);
|
|
2101
2107
|
return inputObjectDefinitionData.node;
|
|
2102
2108
|
}
|
|
2103
2109
|
getCompositeOutputNodeByData(compositeOutputData) {
|
|
2104
2110
|
compositeOutputData.node.description = compositeOutputData.description;
|
|
2105
2111
|
compositeOutputData.node.directives = this.getValidFlattenedDirectiveArray(compositeOutputData.directivesByDirectiveName, compositeOutputData.name);
|
|
2106
|
-
compositeOutputData.node.fields = (0, utils_4.childMapToValueArray)(compositeOutputData.
|
|
2112
|
+
compositeOutputData.node.fields = (0, utils_4.childMapToValueArray)(compositeOutputData.fieldDataByName);
|
|
2107
2113
|
compositeOutputData.node.interfaces = (0, utils_1.setToNamedTypeNodeArray)(compositeOutputData.implementedInterfaceTypeNames);
|
|
2108
2114
|
return compositeOutputData.node;
|
|
2109
2115
|
}
|
|
@@ -2146,10 +2152,10 @@ class NormalizationFactory {
|
|
|
2146
2152
|
const externalExtensionFieldCoordsByRawFieldSet = new Map();
|
|
2147
2153
|
let currentDepth = -1;
|
|
2148
2154
|
let shouldDefineSelectionSet = true;
|
|
2149
|
-
(0,
|
|
2155
|
+
(0, graphql_1.visit)(keyFieldSetData.documentNode, {
|
|
2150
2156
|
Argument: {
|
|
2151
2157
|
enter() {
|
|
2152
|
-
return
|
|
2158
|
+
return graphql_1.BREAK;
|
|
2153
2159
|
},
|
|
2154
2160
|
},
|
|
2155
2161
|
Field: {
|
|
@@ -2158,16 +2164,16 @@ class NormalizationFactory {
|
|
|
2158
2164
|
const parentTypeName = parentData.name;
|
|
2159
2165
|
// If a composite type was just visited, a selection set should have been entered
|
|
2160
2166
|
if (shouldDefineSelectionSet) {
|
|
2161
|
-
return
|
|
2167
|
+
return graphql_1.BREAK;
|
|
2162
2168
|
}
|
|
2163
2169
|
const fieldName = node.name.value;
|
|
2164
2170
|
const fieldCoords = `${parentTypeName}.${fieldName}`;
|
|
2165
2171
|
// If a field declared @external is a key field, it is valid use of @external.
|
|
2166
2172
|
nf.unvalidatedExternalFieldCoords.delete(fieldCoords);
|
|
2167
|
-
const fieldData = parentData.
|
|
2173
|
+
const fieldData = parentData.fieldDataByName.get(fieldName);
|
|
2168
2174
|
// undefined if the field does not exist on the parent
|
|
2169
|
-
if (!fieldData || fieldData.
|
|
2170
|
-
return
|
|
2175
|
+
if (!fieldData || fieldData.argumentDataByName.size) {
|
|
2176
|
+
return graphql_1.BREAK;
|
|
2171
2177
|
}
|
|
2172
2178
|
// Fields that form part of an entity key are intrinsically shareable
|
|
2173
2179
|
fieldData.isShareableBySubgraphName.set(nf.subgraphName, true);
|
|
@@ -2211,7 +2217,7 @@ class NormalizationFactory {
|
|
|
2211
2217
|
// The child could itself be a parent
|
|
2212
2218
|
const namedTypeData = nf.parentDefinitionDataByTypeName.get(namedTypeName);
|
|
2213
2219
|
if (!namedTypeData) {
|
|
2214
|
-
return
|
|
2220
|
+
return graphql_1.BREAK;
|
|
2215
2221
|
}
|
|
2216
2222
|
if (namedTypeData.kind === graphql_1.Kind.OBJECT_TYPE_DEFINITION) {
|
|
2217
2223
|
shouldDefineSelectionSet = true;
|
|
@@ -2220,24 +2226,24 @@ class NormalizationFactory {
|
|
|
2220
2226
|
}
|
|
2221
2227
|
// interfaces and unions are invalid in a key directive
|
|
2222
2228
|
if ((0, utils_1.isKindAbstract)(namedTypeData.kind)) {
|
|
2223
|
-
return
|
|
2229
|
+
return graphql_1.BREAK;
|
|
2224
2230
|
}
|
|
2225
2231
|
},
|
|
2226
2232
|
},
|
|
2227
2233
|
InlineFragment: {
|
|
2228
2234
|
enter() {
|
|
2229
|
-
return
|
|
2235
|
+
return graphql_1.BREAK;
|
|
2230
2236
|
},
|
|
2231
2237
|
},
|
|
2232
2238
|
SelectionSet: {
|
|
2233
2239
|
enter() {
|
|
2234
2240
|
if (!shouldDefineSelectionSet) {
|
|
2235
|
-
return
|
|
2241
|
+
return graphql_1.BREAK;
|
|
2236
2242
|
}
|
|
2237
2243
|
currentDepth += 1;
|
|
2238
2244
|
shouldDefineSelectionSet = false;
|
|
2239
2245
|
if (currentDepth < 0 || currentDepth >= parentDatas.length) {
|
|
2240
|
-
return
|
|
2246
|
+
return graphql_1.BREAK;
|
|
2241
2247
|
}
|
|
2242
2248
|
},
|
|
2243
2249
|
leave() {
|
|
@@ -2359,63 +2365,101 @@ class NormalizationFactory {
|
|
|
2359
2365
|
* */
|
|
2360
2366
|
for (const data of this.invalidConfigureDescriptionNodeDatas) {
|
|
2361
2367
|
if (!data.description) {
|
|
2362
|
-
this.errors.push((0, errors_1.configureDescriptionNoDescriptionError)((0, utils_5.
|
|
2368
|
+
this.errors.push((0, errors_1.configureDescriptionNoDescriptionError)((0, utils_5.kindToNodeType)(data.kind), data.name));
|
|
2363
2369
|
}
|
|
2364
2370
|
}
|
|
2365
2371
|
// Check all key field sets for @external fields to assess whether they are conditional
|
|
2366
2372
|
this.evaluateExternalKeyFields();
|
|
2367
|
-
for (const [parentTypeName,
|
|
2368
|
-
switch (
|
|
2373
|
+
for (const [parentTypeName, parentData] of this.parentDefinitionDataByTypeName) {
|
|
2374
|
+
switch (parentData.kind) {
|
|
2369
2375
|
case graphql_1.Kind.ENUM_TYPE_DEFINITION:
|
|
2370
|
-
if (
|
|
2376
|
+
if (parentData.enumValueDataByValueName.size < 1) {
|
|
2371
2377
|
this.errors.push((0, errors_1.noDefinedEnumValuesError)(parentTypeName));
|
|
2372
2378
|
break;
|
|
2373
2379
|
}
|
|
2374
|
-
definitions.push(this.getEnumNodeByData(
|
|
2380
|
+
definitions.push(this.getEnumNodeByData(parentData));
|
|
2375
2381
|
break;
|
|
2376
2382
|
case graphql_1.Kind.INPUT_OBJECT_TYPE_DEFINITION:
|
|
2377
|
-
if (
|
|
2383
|
+
if (parentData.inputValueDataByName.size < 1) {
|
|
2378
2384
|
this.errors.push((0, errors_1.noInputValueDefinitionsError)(parentTypeName));
|
|
2379
2385
|
break;
|
|
2380
2386
|
}
|
|
2381
|
-
|
|
2387
|
+
for (const valueData of parentData.inputValueDataByName.values()) {
|
|
2388
|
+
// Base Scalars have already been set
|
|
2389
|
+
if (valueData.namedTypeKind !== graphql_1.Kind.NULL) {
|
|
2390
|
+
continue;
|
|
2391
|
+
}
|
|
2392
|
+
const namedTypeData = this.parentDefinitionDataByTypeName.get(valueData.namedTypeName);
|
|
2393
|
+
if (!namedTypeData) {
|
|
2394
|
+
// undefined types are handled elsewhere
|
|
2395
|
+
continue;
|
|
2396
|
+
}
|
|
2397
|
+
if (!(0, utils_4.isInputNodeKind)(namedTypeData.kind)) {
|
|
2398
|
+
this.errors.push((0, errors_1.invalidNamedTypeError)({
|
|
2399
|
+
data: valueData,
|
|
2400
|
+
namedTypeData,
|
|
2401
|
+
nodeType: `${(0, utils_5.kindToNodeType)(parentData.kind)} field`,
|
|
2402
|
+
}));
|
|
2403
|
+
continue;
|
|
2404
|
+
}
|
|
2405
|
+
valueData.namedTypeKind = namedTypeData.kind;
|
|
2406
|
+
}
|
|
2407
|
+
definitions.push(this.getInputObjectNodeByData(parentData));
|
|
2382
2408
|
break;
|
|
2383
2409
|
case graphql_1.Kind.INTERFACE_TYPE_DEFINITION:
|
|
2384
2410
|
// intentional fallthrough
|
|
2385
2411
|
case graphql_1.Kind.OBJECT_TYPE_DEFINITION:
|
|
2386
2412
|
const isEntity = this.entityDataByTypeName.has(parentTypeName);
|
|
2387
2413
|
const operationTypeNode = this.operationTypeNodeByTypeName.get(parentTypeName);
|
|
2388
|
-
const isObject =
|
|
2389
|
-
if (this.isSubgraphVersionTwo &&
|
|
2414
|
+
const isObject = parentData.kind === graphql_1.Kind.OBJECT_TYPE_DEFINITION;
|
|
2415
|
+
if (this.isSubgraphVersionTwo && parentData.extensionType === types_1.ExtensionType.EXTENDS) {
|
|
2390
2416
|
// @extends is essentially ignored in V2. It was only propagated to handle @external key fields.
|
|
2391
|
-
|
|
2417
|
+
parentData.extensionType = types_1.ExtensionType.NONE;
|
|
2392
2418
|
}
|
|
2393
2419
|
if (operationTypeNode) {
|
|
2394
|
-
|
|
2395
|
-
|
|
2420
|
+
parentData.fieldDataByName.delete(string_constants_2.SERVICE_FIELD);
|
|
2421
|
+
parentData.fieldDataByName.delete(string_constants_2.ENTITIES_FIELD);
|
|
2396
2422
|
}
|
|
2397
|
-
(0, utils_4.removeInheritableDirectivesFromObjectParent)(
|
|
2398
|
-
|
|
2399
|
-
|
|
2400
|
-
|
|
2401
|
-
|
|
2402
|
-
externalInterfaceFieldNames.push(fieldName);
|
|
2403
|
-
}
|
|
2404
|
-
// Arguments can only be fully validated once all parents types are known
|
|
2405
|
-
this.validateArguments(fieldData, `${parentTypeName}.${fieldName}`);
|
|
2423
|
+
(0, utils_4.removeInheritableDirectivesFromObjectParent)(parentData);
|
|
2424
|
+
const externalInterfaceFieldNames = [];
|
|
2425
|
+
for (const [fieldName, fieldData] of parentData.fieldDataByName) {
|
|
2426
|
+
if (!isObject && fieldData.externalFieldDataBySubgraphName.get(this.subgraphName)?.isDefinedExternal) {
|
|
2427
|
+
externalInterfaceFieldNames.push(fieldName);
|
|
2406
2428
|
}
|
|
2407
|
-
//
|
|
2408
|
-
|
|
2409
|
-
|
|
2410
|
-
|
|
2411
|
-
|
|
2429
|
+
// Arguments can only be fully validated once all parents types are known
|
|
2430
|
+
this.validateArguments(fieldData, parentData.kind);
|
|
2431
|
+
// Base Scalars have already been set
|
|
2432
|
+
if (fieldData.namedTypeKind !== graphql_1.Kind.NULL) {
|
|
2433
|
+
continue;
|
|
2434
|
+
}
|
|
2435
|
+
const namedTypeData = this.parentDefinitionDataByTypeName.get(fieldData.namedTypeName);
|
|
2436
|
+
if (!namedTypeData) {
|
|
2437
|
+
// undefined types are handled elsewhere
|
|
2438
|
+
continue;
|
|
2412
2439
|
}
|
|
2440
|
+
if (!(0, utils_4.isOutputNodeKind)(namedTypeData.kind)) {
|
|
2441
|
+
this.errors.push((0, errors_1.invalidNamedTypeError)({
|
|
2442
|
+
data: fieldData,
|
|
2443
|
+
namedTypeData,
|
|
2444
|
+
nodeType: `${(0, utils_5.kindToNodeType)(parentData.kind)} field`,
|
|
2445
|
+
}));
|
|
2446
|
+
continue;
|
|
2447
|
+
}
|
|
2448
|
+
fieldData.namedTypeKind = this.entityInterfaceDataByTypeName.get(namedTypeData.name)
|
|
2449
|
+
? graphql_1.Kind.INTERFACE_TYPE_DEFINITION
|
|
2450
|
+
: namedTypeData.kind;
|
|
2451
|
+
}
|
|
2452
|
+
// @external interface fields fails composition in V2; only propagate as a warning for V1.
|
|
2453
|
+
if (externalInterfaceFieldNames.length > 0) {
|
|
2454
|
+
this.isSubgraphVersionTwo
|
|
2455
|
+
? this.errors.push((0, errors_1.externalInterfaceFieldsError)(parentTypeName, externalInterfaceFieldNames))
|
|
2456
|
+
: this.warnings.push((0, warnings_1.externalInterfaceFieldsWarning)(this.subgraphName, parentTypeName, externalInterfaceFieldNames));
|
|
2413
2457
|
}
|
|
2414
|
-
const newParentTypeName = (0, utils_4.getParentTypeName)(
|
|
2458
|
+
const newParentTypeName = (0, utils_4.getParentTypeName)(parentData);
|
|
2415
2459
|
const configurationData = (0, utils_5.getValueOrDefault)(this.configurationDataByTypeName, newParentTypeName, () => (0, utils_6.newConfigurationData)(isEntity, parentTypeName));
|
|
2416
2460
|
const entityInterfaceData = this.entityInterfaceDataByTypeName.get(parentTypeName);
|
|
2417
2461
|
if (entityInterfaceData) {
|
|
2418
|
-
entityInterfaceData.fieldDatas = (0, utils_3.fieldDatasToSimpleFieldDatas)(
|
|
2462
|
+
entityInterfaceData.fieldDatas = (0, utils_3.fieldDatasToSimpleFieldDatas)(parentData.fieldDataByName.values());
|
|
2419
2463
|
const concreteTypeNames = this.concreteTypeNamesByAbstractTypeName.get(parentTypeName);
|
|
2420
2464
|
if (concreteTypeNames) {
|
|
2421
2465
|
(0, utils_5.addIterableValuesToSet)(concreteTypeNames, entityInterfaceData.concreteTypeNames);
|
|
@@ -2427,24 +2471,24 @@ class NormalizationFactory {
|
|
|
2427
2471
|
if (events) {
|
|
2428
2472
|
configurationData.events = events;
|
|
2429
2473
|
}
|
|
2430
|
-
this.addFieldNamesToConfigurationData(
|
|
2431
|
-
this.validateInterfaceImplementations(
|
|
2432
|
-
definitions.push(this.getCompositeOutputNodeByData(
|
|
2474
|
+
this.addFieldNamesToConfigurationData(parentData.fieldDataByName, configurationData);
|
|
2475
|
+
this.validateInterfaceImplementations(parentData);
|
|
2476
|
+
definitions.push(this.getCompositeOutputNodeByData(parentData));
|
|
2433
2477
|
// interfaces and objects must define at least one field
|
|
2434
|
-
if (
|
|
2435
|
-
this.errors.push((0, errors_1.noFieldDefinitionsError)((0, utils_5.
|
|
2478
|
+
if (parentData.fieldDataByName.size < 1 && !(0, utils_2.isNodeQuery)(parentTypeName, operationTypeNode)) {
|
|
2479
|
+
this.errors.push((0, errors_1.noFieldDefinitionsError)((0, utils_5.kindToNodeType)(parentData.kind), parentTypeName));
|
|
2436
2480
|
}
|
|
2437
2481
|
break;
|
|
2438
2482
|
case graphql_1.Kind.SCALAR_TYPE_DEFINITION:
|
|
2439
|
-
if (
|
|
2483
|
+
if (parentData.extensionType === types_1.ExtensionType.REAL) {
|
|
2440
2484
|
this.errors.push((0, errors_1.noBaseScalarDefinitionError)(parentTypeName));
|
|
2441
2485
|
break;
|
|
2442
2486
|
}
|
|
2443
|
-
definitions.push(this.getScalarNodeByData(
|
|
2487
|
+
definitions.push(this.getScalarNodeByData(parentData));
|
|
2444
2488
|
break;
|
|
2445
2489
|
case graphql_1.Kind.UNION_TYPE_DEFINITION:
|
|
2446
|
-
definitions.push(this.getUnionNodeByData(
|
|
2447
|
-
this.validateUnionMembers(
|
|
2490
|
+
definitions.push(this.getUnionNodeByData(parentData));
|
|
2491
|
+
this.validateUnionMembers(parentData);
|
|
2448
2492
|
break;
|
|
2449
2493
|
default:
|
|
2450
2494
|
throw (0, errors_1.unexpectedKindFatalError)(parentTypeName);
|
|
@@ -2493,20 +2537,18 @@ class NormalizationFactory {
|
|
|
2493
2537
|
}
|
|
2494
2538
|
for (const referencedTypeName of this.referencedTypeNames) {
|
|
2495
2539
|
const parentData = this.parentDefinitionDataByTypeName.get(referencedTypeName);
|
|
2496
|
-
if (parentData) {
|
|
2497
|
-
|
|
2498
|
-
continue;
|
|
2499
|
-
}
|
|
2500
|
-
// There will be a run time error if a Field can return an interface without any Object implementations.
|
|
2501
|
-
const implementationTypeNames = this.concreteTypeNamesByAbstractTypeName.get(referencedTypeName);
|
|
2502
|
-
if (!implementationTypeNames || implementationTypeNames.size < 0) {
|
|
2503
|
-
// Temporarily propagate as a warning until @inaccessible, entity interfaces and other such considerations are handled
|
|
2504
|
-
this.warnings.push((0, warnings_1.unimplementedInterfaceOutputTypeWarning)(this.subgraphName, referencedTypeName));
|
|
2505
|
-
}
|
|
2540
|
+
if (!parentData) {
|
|
2541
|
+
this.errors.push((0, errors_1.undefinedTypeError)(referencedTypeName));
|
|
2506
2542
|
continue;
|
|
2507
2543
|
}
|
|
2508
|
-
if (
|
|
2509
|
-
|
|
2544
|
+
if (parentData.kind !== graphql_1.Kind.INTERFACE_TYPE_DEFINITION) {
|
|
2545
|
+
continue;
|
|
2546
|
+
}
|
|
2547
|
+
// There will be a run time error if a field can return an Interface without any Object implementations.
|
|
2548
|
+
const implementationTypeNames = this.concreteTypeNamesByAbstractTypeName.get(referencedTypeName);
|
|
2549
|
+
if (!implementationTypeNames || implementationTypeNames.size < 0) {
|
|
2550
|
+
// Temporarily propagate as a warning until @inaccessible, entity interfaces and other such considerations are handled
|
|
2551
|
+
this.warnings.push((0, warnings_1.unimplementedInterfaceOutputTypeWarning)(this.subgraphName, referencedTypeName));
|
|
2510
2552
|
}
|
|
2511
2553
|
}
|
|
2512
2554
|
const persistedDirectiveDefinitionDataByDirectiveName = new Map();
|