@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
|
@@ -36,10 +36,10 @@ class FederationFactory {
|
|
|
36
36
|
fieldCoordsByNamedTypeName;
|
|
37
37
|
inaccessibleCoords = new Set();
|
|
38
38
|
inaccessibleRequiredInputValueErrorByCoords = new Map();
|
|
39
|
-
isMaxDepth = false;
|
|
40
39
|
internalGraph;
|
|
41
40
|
internalSubgraphBySubgraphName;
|
|
42
41
|
invalidORScopesCoords = new Set();
|
|
42
|
+
isMaxDepth = false;
|
|
43
43
|
isVersionTwo = false;
|
|
44
44
|
namedInputValueTypeNames = new Set();
|
|
45
45
|
namedOutputTypeNames = new Set();
|
|
@@ -81,7 +81,7 @@ class FederationFactory {
|
|
|
81
81
|
interfaces.push((0, utils_1.stringToNamedTypeNode)(interfaceName));
|
|
82
82
|
const implementationData = (0, utils_6.getOrThrowError)(this.parentDefinitionDataByTypeName, interfaceName, string_constants_2.PARENT_DEFINITION_DATA);
|
|
83
83
|
if (implementationData.kind !== graphql_1.Kind.INTERFACE_TYPE_DEFINITION) {
|
|
84
|
-
invalidImplementationTypeStringByTypeName.set(implementationData.name, (0, utils_6.
|
|
84
|
+
invalidImplementationTypeStringByTypeName.set(implementationData.name, (0, utils_6.kindToNodeType)(implementationData.kind));
|
|
85
85
|
continue;
|
|
86
86
|
}
|
|
87
87
|
const implementationErrors = {
|
|
@@ -89,9 +89,9 @@ class FederationFactory {
|
|
|
89
89
|
unimplementedFields: [],
|
|
90
90
|
};
|
|
91
91
|
let hasErrors = false;
|
|
92
|
-
for (const [fieldName, interfaceField] of implementationData.
|
|
92
|
+
for (const [fieldName, interfaceField] of implementationData.fieldDataByName) {
|
|
93
93
|
let hasNestedErrors = false;
|
|
94
|
-
const fieldData = data.
|
|
94
|
+
const fieldData = data.fieldDataByName.get(fieldName);
|
|
95
95
|
if (!fieldData) {
|
|
96
96
|
hasErrors = true;
|
|
97
97
|
implementationErrors.unimplementedFields.push(fieldName);
|
|
@@ -111,10 +111,10 @@ class FederationFactory {
|
|
|
111
111
|
invalidFieldImplementation.implementedResponseType = (0, merge_1.printTypeNode)(fieldData.node.type);
|
|
112
112
|
}
|
|
113
113
|
const handledArguments = new Set();
|
|
114
|
-
for (const [argumentName, inputValueData] of interfaceField.
|
|
114
|
+
for (const [argumentName, inputValueData] of interfaceField.argumentDataByName) {
|
|
115
115
|
const interfaceArgument = inputValueData.node;
|
|
116
116
|
handledArguments.add(argumentName);
|
|
117
|
-
const argumentNode = fieldData.
|
|
117
|
+
const argumentNode = fieldData.argumentDataByName.get(argumentName)?.node;
|
|
118
118
|
// The type implementing the interface must include all arguments with no variation for that argument
|
|
119
119
|
if (!argumentNode) {
|
|
120
120
|
hasErrors = true;
|
|
@@ -132,7 +132,7 @@ class FederationFactory {
|
|
|
132
132
|
}
|
|
133
133
|
}
|
|
134
134
|
// Additional arguments must be optional (nullable)
|
|
135
|
-
for (const [argumentName, inputValueContainer] of fieldData.
|
|
135
|
+
for (const [argumentName, inputValueContainer] of fieldData.argumentDataByName) {
|
|
136
136
|
const argumentNode = inputValueContainer.node;
|
|
137
137
|
if (handledArguments.has(argumentName)) {
|
|
138
138
|
continue;
|
|
@@ -161,7 +161,7 @@ class FederationFactory {
|
|
|
161
161
|
this.errors.push((0, errors_1.invalidImplementedTypeError)(data.name, invalidImplementationTypeStringByTypeName));
|
|
162
162
|
}
|
|
163
163
|
if (implementationErrorsByInterfaceName.size > 0) {
|
|
164
|
-
this.errors.push((0, errors_1.invalidInterfaceImplementationError)(data.node.name.value, (0, utils_6.
|
|
164
|
+
this.errors.push((0, errors_1.invalidInterfaceImplementationError)(data.node.name.value, (0, utils_6.kindToNodeType)(data.kind), implementationErrorsByInterfaceName));
|
|
165
165
|
}
|
|
166
166
|
return interfaces;
|
|
167
167
|
}
|
|
@@ -338,17 +338,17 @@ class FederationFactory {
|
|
|
338
338
|
(0, utils_6.addIterableValuesToSet)(incomingData.subgraphNames, targetData.subgraphNames);
|
|
339
339
|
this.handleInputValueInaccessibility(isParentInaccessible, targetData, parentCoords);
|
|
340
340
|
// TODO refactor type merging
|
|
341
|
-
const
|
|
342
|
-
if (
|
|
343
|
-
targetData.type = typeNode;
|
|
341
|
+
const mergeResult = (0, type_merging_1.getMostRestrictiveMergedTypeNode)(targetData.type, incomingData.type, targetData.originalCoords, this.errors);
|
|
342
|
+
if (mergeResult.success) {
|
|
343
|
+
targetData.type = mergeResult.typeNode;
|
|
344
344
|
}
|
|
345
345
|
else {
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
346
|
+
this.errors.push((0, errors_1.incompatibleMergedTypesError)({
|
|
347
|
+
actualType: mergeResult.actualType,
|
|
348
|
+
isArgument: existingData.isArgument,
|
|
349
|
+
coords: existingData.federatedCoords,
|
|
350
|
+
expectedType: mergeResult.expectedType,
|
|
351
|
+
}));
|
|
352
352
|
}
|
|
353
353
|
(0, utils_5.compareAndValidateInputValueDefaultValues)(targetData, incomingData, this.errors);
|
|
354
354
|
}
|
|
@@ -392,7 +392,7 @@ class FederationFactory {
|
|
|
392
392
|
federateOutputType({ current, other, coords, mostRestrictive }) {
|
|
393
393
|
other = (0, ast_1.getMutableTypeNode)(other, coords, this.errors); // current is already a deep copy
|
|
394
394
|
// The first type of the pair to diverge in restriction takes precedence in all future differences.
|
|
395
|
-
// If the other type of the pair also diverges, it's
|
|
395
|
+
// If the other type of the pair also diverges, it's an error.
|
|
396
396
|
// To keep the output link intact, it is not possible to spread assign "lastTypeNode".
|
|
397
397
|
const federatedTypeNode = { kind: current.kind };
|
|
398
398
|
let divergentType = type_merging_1.DivergentType.NONE;
|
|
@@ -422,7 +422,7 @@ class FederationFactory {
|
|
|
422
422
|
}
|
|
423
423
|
if (current.kind === graphql_1.Kind.NON_NULL_TYPE) {
|
|
424
424
|
if (divergentType === type_merging_1.DivergentType.OTHER) {
|
|
425
|
-
this.errors.push((0, errors_1.
|
|
425
|
+
this.errors.push((0, errors_1.incompatibleMergedTypesError)({ actualType: other.kind, coords, expectedType: current.kind }));
|
|
426
426
|
return { success: false };
|
|
427
427
|
}
|
|
428
428
|
else {
|
|
@@ -438,7 +438,7 @@ class FederationFactory {
|
|
|
438
438
|
}
|
|
439
439
|
if (other.kind === graphql_1.Kind.NON_NULL_TYPE) {
|
|
440
440
|
if (divergentType === type_merging_1.DivergentType.CURRENT) {
|
|
441
|
-
this.errors.push((0, errors_1.
|
|
441
|
+
this.errors.push((0, errors_1.incompatibleMergedTypesError)({ actualType: other.kind, coords, expectedType: current.kind }));
|
|
442
442
|
return { success: false };
|
|
443
443
|
}
|
|
444
444
|
else {
|
|
@@ -453,7 +453,7 @@ class FederationFactory {
|
|
|
453
453
|
continue;
|
|
454
454
|
}
|
|
455
455
|
// At least one of the types must be a non-null wrapper, or the types are inconsistent
|
|
456
|
-
this.errors.push((0, errors_1.
|
|
456
|
+
this.errors.push((0, errors_1.incompatibleMergedTypesError)({ actualType: other.kind, coords, expectedType: current.kind }));
|
|
457
457
|
return { success: false };
|
|
458
458
|
}
|
|
459
459
|
this.errors.push((0, errors_1.maximumTypeNestingExceededError)(coords));
|
|
@@ -513,8 +513,8 @@ class FederationFactory {
|
|
|
513
513
|
this.addSubgraphNameToExistingFieldNamedTypeDisparity(incomingData);
|
|
514
514
|
}
|
|
515
515
|
}
|
|
516
|
-
for (const inputValueData of incomingData.
|
|
517
|
-
this.upsertInputValueData(targetData.
|
|
516
|
+
for (const inputValueData of incomingData.argumentDataByName.values()) {
|
|
517
|
+
this.upsertInputValueData(targetData.argumentDataByName, inputValueData, targetData.federatedCoords, isFieldInaccessible);
|
|
518
518
|
}
|
|
519
519
|
(0, utils_6.addNewObjectValueMapEntries)(incomingData.configureDescriptionDataBySubgraphName, existingData.configureDescriptionDataBySubgraphName);
|
|
520
520
|
(0, utils_5.setLongestDescription)(targetData, incomingData);
|
|
@@ -575,10 +575,13 @@ class FederationFactory {
|
|
|
575
575
|
return {
|
|
576
576
|
configureDescriptionDataBySubgraphName: (0, utils_6.copyObjectValueMap)(sourceData.configureDescriptionDataBySubgraphName),
|
|
577
577
|
directivesByDirectiveName: (0, utils_6.copyArrayValueMap)(sourceData.directivesByDirectiveName),
|
|
578
|
+
federatedCoords: sourceData.federatedCoords,
|
|
579
|
+
fieldName: sourceData.fieldName,
|
|
578
580
|
includeDefaultValue: sourceData.includeDefaultValue,
|
|
579
581
|
isArgument: sourceData.isArgument,
|
|
580
582
|
kind: sourceData.kind,
|
|
581
583
|
name: sourceData.name,
|
|
584
|
+
namedTypeKind: sourceData.namedTypeKind,
|
|
582
585
|
namedTypeName: sourceData.namedTypeName,
|
|
583
586
|
node: {
|
|
584
587
|
directives: [],
|
|
@@ -587,8 +590,9 @@ class FederationFactory {
|
|
|
587
590
|
type: sourceData.type,
|
|
588
591
|
},
|
|
589
592
|
originalCoords: sourceData.originalCoords,
|
|
593
|
+
originalParentTypeName: sourceData.originalParentTypeName,
|
|
590
594
|
persistedDirectivesData: (0, utils_5.extractPersistedDirectives)((0, utils_5.newPersistedDirectivesData)(), sourceData.directivesByDirectiveName, this.persistedDirectiveDefinitionByDirectiveName),
|
|
591
|
-
|
|
595
|
+
renamedParentTypeName: sourceData.renamedParentTypeName,
|
|
592
596
|
requiredSubgraphNames: new Set(sourceData.requiredSubgraphNames),
|
|
593
597
|
subgraphNames: new Set(sourceData.subgraphNames),
|
|
594
598
|
type: sourceData.type,
|
|
@@ -610,7 +614,7 @@ class FederationFactory {
|
|
|
610
614
|
}
|
|
611
615
|
copyFieldData(sourceData, isInaccessible) {
|
|
612
616
|
return {
|
|
613
|
-
|
|
617
|
+
argumentDataByName: this.copyInputValueDataByValueName(sourceData.argumentDataByName, isInaccessible, sourceData.federatedCoords),
|
|
614
618
|
configureDescriptionDataBySubgraphName: (0, utils_6.copyObjectValueMap)(sourceData.configureDescriptionDataBySubgraphName),
|
|
615
619
|
directivesByDirectiveName: (0, utils_6.copyArrayValueMap)(sourceData.directivesByDirectiveName),
|
|
616
620
|
externalFieldDataBySubgraphName: (0, utils_6.copyObjectValueMap)(sourceData.externalFieldDataBySubgraphName),
|
|
@@ -619,6 +623,7 @@ class FederationFactory {
|
|
|
619
623
|
isShareableBySubgraphName: new Map(sourceData.isShareableBySubgraphName),
|
|
620
624
|
kind: sourceData.kind,
|
|
621
625
|
name: sourceData.name,
|
|
626
|
+
namedTypeKind: sourceData.namedTypeKind,
|
|
622
627
|
namedTypeName: sourceData.namedTypeName,
|
|
623
628
|
node: {
|
|
624
629
|
arguments: [],
|
|
@@ -647,7 +652,7 @@ class FederationFactory {
|
|
|
647
652
|
}
|
|
648
653
|
return output;
|
|
649
654
|
}
|
|
650
|
-
|
|
655
|
+
copyFieldDataByName(source, isParentInaccessible) {
|
|
651
656
|
const fieldDataByFieldName = new Map();
|
|
652
657
|
for (const [fieldName, sourceData] of source) {
|
|
653
658
|
const isFieldInaccessible = isParentInaccessible || (0, utils_5.isNodeDataInaccessible)(sourceData);
|
|
@@ -683,7 +688,7 @@ class FederationFactory {
|
|
|
683
688
|
case graphql_1.Kind.INPUT_OBJECT_TYPE_DEFINITION: {
|
|
684
689
|
return {
|
|
685
690
|
...data,
|
|
686
|
-
|
|
691
|
+
inputValueDataByName: this.copyInputValueDataByValueName(sourceData.inputValueDataByName, sourceData.isInaccessible, sourceData.name),
|
|
687
692
|
isInaccessible: sourceData.isInaccessible,
|
|
688
693
|
kind: sourceData.kind,
|
|
689
694
|
node: {
|
|
@@ -696,7 +701,7 @@ class FederationFactory {
|
|
|
696
701
|
case graphql_1.Kind.INTERFACE_TYPE_DEFINITION: {
|
|
697
702
|
return {
|
|
698
703
|
...data,
|
|
699
|
-
|
|
704
|
+
fieldDataByName: this.copyFieldDataByName(sourceData.fieldDataByName, sourceData.isInaccessible),
|
|
700
705
|
implementedInterfaceTypeNames: new Set(sourceData.implementedInterfaceTypeNames),
|
|
701
706
|
isEntity: sourceData.isEntity,
|
|
702
707
|
isInaccessible: sourceData.isInaccessible,
|
|
@@ -711,7 +716,7 @@ class FederationFactory {
|
|
|
711
716
|
case graphql_1.Kind.OBJECT_TYPE_DEFINITION: {
|
|
712
717
|
return {
|
|
713
718
|
...data,
|
|
714
|
-
|
|
719
|
+
fieldDataByName: this.copyFieldDataByName(sourceData.fieldDataByName, sourceData.isInaccessible),
|
|
715
720
|
implementedInterfaceTypeNames: new Set(sourceData.implementedInterfaceTypeNames),
|
|
716
721
|
isEntity: sourceData.isEntity,
|
|
717
722
|
isInaccessible: sourceData.isInaccessible,
|
|
@@ -783,7 +788,7 @@ class FederationFactory {
|
|
|
783
788
|
!entityInterfaceData.interfaceObjectSubgraphs.has(subgraphName) ||
|
|
784
789
|
targetData.kind !== graphql_1.Kind.INTERFACE_TYPE_DEFINITION ||
|
|
785
790
|
incomingData.kind !== graphql_1.Kind.OBJECT_TYPE_DEFINITION) {
|
|
786
|
-
this.errors.push((0, errors_1.incompatibleParentKindMergeError)(targetData.name, (0, utils_6.
|
|
791
|
+
this.errors.push((0, errors_1.incompatibleParentKindMergeError)(targetData.name, (0, utils_6.kindToNodeType)(targetData.kind), (0, utils_6.kindToNodeType)(incomingData.kind)));
|
|
787
792
|
return;
|
|
788
793
|
}
|
|
789
794
|
}
|
|
@@ -812,8 +817,8 @@ class FederationFactory {
|
|
|
812
817
|
}
|
|
813
818
|
targetData.isInaccessible ||= isParentInaccessible;
|
|
814
819
|
(0, utils_6.addIterableValuesToSet)(incomingData.subgraphNames, targetData.subgraphNames);
|
|
815
|
-
for (const inputValueData of incomingData.
|
|
816
|
-
this.upsertInputValueData(targetData.
|
|
820
|
+
for (const inputValueData of incomingData.inputValueDataByName.values()) {
|
|
821
|
+
this.upsertInputValueData(targetData.inputValueDataByName, inputValueData, targetData.name, targetData.isInaccessible);
|
|
817
822
|
}
|
|
818
823
|
return;
|
|
819
824
|
case graphql_1.Kind.INTERFACE_TYPE_DEFINITION:
|
|
@@ -828,8 +833,8 @@ class FederationFactory {
|
|
|
828
833
|
targetData.isInaccessible ||= isParentInaccessible;
|
|
829
834
|
(0, utils_6.addIterableValuesToSet)(compositeOutputData.implementedInterfaceTypeNames, targetData.implementedInterfaceTypeNames);
|
|
830
835
|
(0, utils_6.addIterableValuesToSet)(compositeOutputData.subgraphNames, targetData.subgraphNames);
|
|
831
|
-
for (const fieldData of compositeOutputData.
|
|
832
|
-
this.upsertFieldData(targetData.
|
|
836
|
+
for (const fieldData of compositeOutputData.fieldDataByName.values()) {
|
|
837
|
+
this.upsertFieldData(targetData.fieldDataByName, fieldData, targetData.isInaccessible);
|
|
833
838
|
}
|
|
834
839
|
return;
|
|
835
840
|
case graphql_1.Kind.UNION_TYPE_DEFINITION:
|
|
@@ -848,14 +853,14 @@ class FederationFactory {
|
|
|
848
853
|
propagateInaccessibilityToExistingChildren(data) {
|
|
849
854
|
switch (data.kind) {
|
|
850
855
|
case graphql_1.Kind.INPUT_OBJECT_TYPE_DEFINITION:
|
|
851
|
-
for (const inputFieldData of data.
|
|
856
|
+
for (const inputFieldData of data.inputValueDataByName.values()) {
|
|
852
857
|
this.inaccessibleCoords.add(inputFieldData.federatedCoords);
|
|
853
858
|
}
|
|
854
859
|
break;
|
|
855
860
|
default:
|
|
856
|
-
for (const fieldData of data.
|
|
861
|
+
for (const fieldData of data.fieldDataByName.values()) {
|
|
857
862
|
this.inaccessibleCoords.add(fieldData.federatedCoords);
|
|
858
|
-
for (const inputValueData of fieldData.
|
|
863
|
+
for (const inputValueData of fieldData.argumentDataByName.values()) {
|
|
859
864
|
this.inaccessibleCoords.add(inputValueData.federatedCoords);
|
|
860
865
|
}
|
|
861
866
|
}
|
|
@@ -942,10 +947,10 @@ class FederationFactory {
|
|
|
942
947
|
// This error should never happen
|
|
943
948
|
if (compositeOutputData.kind !== graphql_1.Kind.INTERFACE_TYPE_DEFINITION &&
|
|
944
949
|
compositeOutputData.kind !== graphql_1.Kind.OBJECT_TYPE_DEFINITION) {
|
|
945
|
-
this.errors.push((0, errors_1.unexpectedNonCompositeOutputTypeError)(coordinates[0], (0, utils_6.
|
|
950
|
+
this.errors.push((0, errors_1.unexpectedNonCompositeOutputTypeError)(coordinates[0], (0, utils_6.kindToNodeType)(compositeOutputData.kind)));
|
|
946
951
|
continue;
|
|
947
952
|
}
|
|
948
|
-
const fieldData = compositeOutputData.
|
|
953
|
+
const fieldData = compositeOutputData.fieldDataByName.get(coordinates[1]);
|
|
949
954
|
// This error should never happen
|
|
950
955
|
if (!fieldData) {
|
|
951
956
|
this.errors.push((0, errors_1.unknownFieldDataError)(fieldCoordinates));
|
|
@@ -1104,26 +1109,21 @@ class FederationFactory {
|
|
|
1104
1109
|
}
|
|
1105
1110
|
for (const subgraphName of entityInterfaceData.interfaceObjectSubgraphs) {
|
|
1106
1111
|
const internalSubgraph = (0, utils_6.getOrThrowError)(this.internalSubgraphBySubgraphName, subgraphName, 'internalSubgraphBySubgraphName');
|
|
1107
|
-
const
|
|
1112
|
+
const configurationDataByTypeName = internalSubgraph.configurationDataByTypeName;
|
|
1108
1113
|
const concreteTypeNames = this.concreteTypeNamesByAbstractTypeName.get(entityInterfaceTypeName);
|
|
1109
1114
|
if (!concreteTypeNames) {
|
|
1110
1115
|
continue;
|
|
1111
1116
|
}
|
|
1112
|
-
const interfaceObjectConfiguration = (0, utils_6.getOrThrowError)(
|
|
1117
|
+
const interfaceObjectConfiguration = (0, utils_6.getOrThrowError)(configurationDataByTypeName, entityInterfaceTypeName, 'configurationDataByTypeName');
|
|
1113
1118
|
const keys = interfaceObjectConfiguration.keys;
|
|
1114
1119
|
if (!keys) {
|
|
1115
1120
|
// TODO no keys error
|
|
1116
1121
|
continue;
|
|
1117
1122
|
}
|
|
1118
1123
|
interfaceObjectConfiguration.entityInterfaceConcreteTypeNames = entityInterfaceData.concreteTypeNames;
|
|
1119
|
-
const fieldNames = interfaceObjectConfiguration.fieldNames;
|
|
1120
1124
|
this.internalGraph.setSubgraphName(subgraphName);
|
|
1121
1125
|
const interfaceObjectNode = this.internalGraph.addOrUpdateNode(entityInterfaceTypeName, { isAbstract: true });
|
|
1122
1126
|
for (const concreteTypeName of concreteTypeNames) {
|
|
1123
|
-
if (configurationDataMap.has(concreteTypeName)) {
|
|
1124
|
-
// error TODO
|
|
1125
|
-
continue;
|
|
1126
|
-
}
|
|
1127
1127
|
const concreteTypeData = (0, utils_6.getOrThrowError)(this.parentDefinitionDataByTypeName, concreteTypeName, string_constants_2.PARENT_DEFINITION_DATA);
|
|
1128
1128
|
if (!(0, utils_3.isObjectDefinitionData)(concreteTypeData)) {
|
|
1129
1129
|
continue;
|
|
@@ -1131,12 +1131,31 @@ class FederationFactory {
|
|
|
1131
1131
|
// The subgraph locations of the interface object must be added to the concrete types that implement it
|
|
1132
1132
|
const entityData = (0, utils_6.getOrThrowError)(this.entityDataByTypeName, concreteTypeName, 'entityDataByTypeName');
|
|
1133
1133
|
entityData.subgraphNames.add(subgraphName);
|
|
1134
|
-
const configurationData =
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
keys
|
|
1138
|
-
|
|
1139
|
-
|
|
1134
|
+
const configurationData = configurationDataByTypeName.get(concreteTypeName);
|
|
1135
|
+
if (configurationData) {
|
|
1136
|
+
(0, utils_6.addIterableValuesToSet)(interfaceObjectConfiguration.fieldNames, configurationData.fieldNames);
|
|
1137
|
+
if (!configurationData.keys) {
|
|
1138
|
+
configurationData.keys = [...keys];
|
|
1139
|
+
}
|
|
1140
|
+
else {
|
|
1141
|
+
parentLoop: for (const key of keys) {
|
|
1142
|
+
for (const { selectionSet } of configurationData.keys) {
|
|
1143
|
+
if (key.selectionSet === selectionSet) {
|
|
1144
|
+
continue parentLoop;
|
|
1145
|
+
}
|
|
1146
|
+
}
|
|
1147
|
+
configurationData.keys.push(key);
|
|
1148
|
+
}
|
|
1149
|
+
}
|
|
1150
|
+
}
|
|
1151
|
+
else {
|
|
1152
|
+
configurationDataByTypeName.set(concreteTypeName, {
|
|
1153
|
+
fieldNames: new Set(interfaceObjectConfiguration.fieldNames),
|
|
1154
|
+
isRootNode: true,
|
|
1155
|
+
keys: [...keys],
|
|
1156
|
+
typeName: concreteTypeName,
|
|
1157
|
+
});
|
|
1158
|
+
}
|
|
1140
1159
|
const resolvableKeyFieldSets = new Set();
|
|
1141
1160
|
for (const key of keys.filter((k) => !k.disableEntityResolver)) {
|
|
1142
1161
|
resolvableKeyFieldSets.add(key.selectionSet);
|
|
@@ -1144,7 +1163,7 @@ class FederationFactory {
|
|
|
1144
1163
|
const interfaceAuthData = this.authorizationDataByParentTypeName.get(entityInterfaceTypeName);
|
|
1145
1164
|
for (const fieldName of entityInterfaceData.interfaceObjectFieldNames) {
|
|
1146
1165
|
const fieldCoords = `${concreteTypeName}.${fieldName}`;
|
|
1147
|
-
const interfaceFieldData = (0, utils_6.getOrThrowError)(entityInterface.
|
|
1166
|
+
const interfaceFieldData = (0, utils_6.getOrThrowError)(entityInterface.fieldDataByName, fieldName, `${entityInterfaceTypeName}.fieldDataByFieldName`);
|
|
1148
1167
|
(0, utils_6.getValueOrDefault)(this.fieldCoordsByNamedTypeName, interfaceFieldData.namedTypeName, () => new Set()).add(fieldCoords);
|
|
1149
1168
|
const interfaceFieldAuthData = interfaceAuthData?.fieldAuthDataByFieldName.get(fieldName);
|
|
1150
1169
|
if (interfaceFieldAuthData) {
|
|
@@ -1153,15 +1172,14 @@ class FederationFactory {
|
|
|
1153
1172
|
this.invalidORScopesCoords.add(fieldCoords);
|
|
1154
1173
|
}
|
|
1155
1174
|
}
|
|
1156
|
-
const existingFieldData = concreteTypeData.
|
|
1175
|
+
const existingFieldData = concreteTypeData.fieldDataByName.get(fieldName);
|
|
1157
1176
|
if (existingFieldData) {
|
|
1158
1177
|
// TODO handle shareability
|
|
1159
1178
|
continue;
|
|
1160
1179
|
}
|
|
1161
1180
|
const isInaccessible = entityInterface.isInaccessible || concreteTypeData.isInaccessible || interfaceFieldData.isInaccessible;
|
|
1162
|
-
concreteTypeData.
|
|
1181
|
+
concreteTypeData.fieldDataByName.set(fieldName, this.copyFieldData(interfaceFieldData, isInaccessible));
|
|
1163
1182
|
}
|
|
1164
|
-
configurationDataMap.set(concreteTypeName, configurationData);
|
|
1165
1183
|
this.handleInterfaceObjectForInternalGraph({
|
|
1166
1184
|
internalSubgraph,
|
|
1167
1185
|
subgraphName,
|
|
@@ -1252,7 +1270,7 @@ class FederationFactory {
|
|
|
1252
1270
|
const argumentNames = [];
|
|
1253
1271
|
const invalidRequiredArguments = [];
|
|
1254
1272
|
const fieldPath = `${fieldData.renamedParentTypeName}.${fieldData.name}`;
|
|
1255
|
-
for (const [argumentName, inputValueData] of fieldData.
|
|
1273
|
+
for (const [argumentName, inputValueData] of fieldData.argumentDataByName) {
|
|
1256
1274
|
if (fieldData.subgraphNames.size === inputValueData.subgraphNames.size) {
|
|
1257
1275
|
argumentNames.push(argumentName);
|
|
1258
1276
|
argumentNodes.push(this.getNodeWithPersistedDirectivesByInputValueData(inputValueData));
|
|
@@ -1289,7 +1307,7 @@ class FederationFactory {
|
|
|
1289
1307
|
pushParentDefinitionDataToDocumentDefinitions(interfaceImplementations) {
|
|
1290
1308
|
for (const [parentTypeName, parentDefinitionData] of this.parentDefinitionDataByTypeName) {
|
|
1291
1309
|
if (parentDefinitionData.extensionType !== types_1.ExtensionType.NONE) {
|
|
1292
|
-
this.errors.push((0, errors_1.noBaseDefinitionForExtensionError)((0, utils_6.
|
|
1310
|
+
this.errors.push((0, errors_1.noBaseDefinitionForExtensionError)((0, utils_6.kindToNodeType)(parentDefinitionData.kind), parentTypeName));
|
|
1293
1311
|
}
|
|
1294
1312
|
switch (parentDefinitionData.kind) {
|
|
1295
1313
|
case graphql_1.Kind.ENUM_TYPE_DEFINITION:
|
|
@@ -1338,7 +1356,7 @@ class FederationFactory {
|
|
|
1338
1356
|
break;
|
|
1339
1357
|
}
|
|
1340
1358
|
if (clientEnumValueNodes.length < 1) {
|
|
1341
|
-
this.errors.push((0, errors_1.allChildDefinitionsAreInaccessibleError)((0, utils_6.
|
|
1359
|
+
this.errors.push((0, errors_1.allChildDefinitionsAreInaccessibleError)((0, utils_6.kindToNodeType)(parentDefinitionData.kind), parentTypeName, string_constants_2.ENUM_VALUE));
|
|
1342
1360
|
break;
|
|
1343
1361
|
}
|
|
1344
1362
|
this.clientDefinitions.push({
|
|
@@ -1351,7 +1369,7 @@ class FederationFactory {
|
|
|
1351
1369
|
const invalidRequiredInputs = [];
|
|
1352
1370
|
const inputValueNodes = [];
|
|
1353
1371
|
const clientInputValueNodes = [];
|
|
1354
|
-
for (const [inputValueName, inputValueData] of parentDefinitionData.
|
|
1372
|
+
for (const [inputValueName, inputValueData] of parentDefinitionData.inputValueDataByName) {
|
|
1355
1373
|
if (parentDefinitionData.subgraphNames.size === inputValueData.subgraphNames.size) {
|
|
1356
1374
|
inputValueNodes.push(this.getNodeWithPersistedDirectivesByInputValueData(inputValueData));
|
|
1357
1375
|
if ((0, utils_5.isNodeDataInaccessible)(inputValueData)) {
|
|
@@ -1381,7 +1399,7 @@ class FederationFactory {
|
|
|
1381
1399
|
break;
|
|
1382
1400
|
}
|
|
1383
1401
|
if (clientInputValueNodes.length < 1) {
|
|
1384
|
-
this.errors.push((0, errors_1.allChildDefinitionsAreInaccessibleError)((0, utils_6.
|
|
1402
|
+
this.errors.push((0, errors_1.allChildDefinitionsAreInaccessibleError)((0, utils_6.kindToNodeType)(parentDefinitionData.kind), parentTypeName, 'input field'));
|
|
1385
1403
|
break;
|
|
1386
1404
|
}
|
|
1387
1405
|
this.clientDefinitions.push({
|
|
@@ -1400,7 +1418,7 @@ class FederationFactory {
|
|
|
1400
1418
|
const isObject = parentDefinitionData.kind === graphql_1.Kind.OBJECT_TYPE_DEFINITION;
|
|
1401
1419
|
const authData = this.authorizationDataByParentTypeName.get(parentTypeName);
|
|
1402
1420
|
(0, utils_5.propagateAuthDirectives)(parentDefinitionData, authData);
|
|
1403
|
-
for (const [fieldName, fieldData] of parentDefinitionData.
|
|
1421
|
+
for (const [fieldName, fieldData] of parentDefinitionData.fieldDataByName) {
|
|
1404
1422
|
(0, utils_5.propagateFieldAuthDirectives)(fieldData, authData);
|
|
1405
1423
|
const argumentNodes = this.getValidFieldArgumentNodes(fieldData);
|
|
1406
1424
|
if (isObject) {
|
|
@@ -1442,7 +1460,7 @@ class FederationFactory {
|
|
|
1442
1460
|
if (clientSchemaFieldNodes.length < 1) {
|
|
1443
1461
|
const error = isQuery
|
|
1444
1462
|
? (0, errors_1.noQueryRootTypeError)(false)
|
|
1445
|
-
: (0, errors_1.allChildDefinitionsAreInaccessibleError)((0, utils_6.
|
|
1463
|
+
: (0, errors_1.allChildDefinitionsAreInaccessibleError)((0, utils_6.kindToNodeType)(parentDefinitionData.kind), parentTypeName, string_constants_2.FIELD);
|
|
1446
1464
|
this.errors.push(error);
|
|
1447
1465
|
break;
|
|
1448
1466
|
}
|
|
@@ -1603,16 +1621,16 @@ class FederationFactory {
|
|
|
1603
1621
|
}
|
|
1604
1622
|
}
|
|
1605
1623
|
if (invalidCoords.length > 0) {
|
|
1606
|
-
this.errors.push((0, errors_1.invalidReferencesOfInaccessibleTypeError)((0, utils_6.
|
|
1624
|
+
this.errors.push((0, errors_1.invalidReferencesOfInaccessibleTypeError)((0, utils_6.kindToNodeType)(data.kind), data.name, invalidCoords));
|
|
1607
1625
|
}
|
|
1608
1626
|
}
|
|
1609
1627
|
validateQueryRootType() {
|
|
1610
1628
|
const query = this.parentDefinitionDataByTypeName.get(string_constants_2.QUERY);
|
|
1611
|
-
if (!query || query.kind !== graphql_1.Kind.OBJECT_TYPE_DEFINITION || query.
|
|
1629
|
+
if (!query || query.kind !== graphql_1.Kind.OBJECT_TYPE_DEFINITION || query.fieldDataByName.size < 1) {
|
|
1612
1630
|
this.errors.push((0, errors_1.noQueryRootTypeError)());
|
|
1613
1631
|
return;
|
|
1614
1632
|
}
|
|
1615
|
-
for (const fieldData of query.
|
|
1633
|
+
for (const fieldData of query.fieldDataByName.values()) {
|
|
1616
1634
|
if (!(0, utils_5.isNodeDataInaccessible)(fieldData)) {
|
|
1617
1635
|
return;
|
|
1618
1636
|
}
|
|
@@ -1638,7 +1656,7 @@ class FederationFactory {
|
|
|
1638
1656
|
fieldErrorMessages.push((0, errors_1.invalidSubscriptionFieldConditionFieldPathParentErrorMessage)(inputFieldPath, conditionFieldPath, partialConditionFieldPath));
|
|
1639
1657
|
return [];
|
|
1640
1658
|
}
|
|
1641
|
-
const fieldData = lastData.
|
|
1659
|
+
const fieldData = lastData.fieldDataByName.get(fieldName);
|
|
1642
1660
|
if (!fieldData) {
|
|
1643
1661
|
fieldErrorMessages.push((0, errors_1.undefinedSubscriptionFieldConditionFieldPathFieldErrorMessage)(inputFieldPath, conditionFieldPath, partialConditionFieldPath, fieldName, lastData.renamedTypeName));
|
|
1644
1662
|
return [];
|
|
@@ -1659,7 +1677,7 @@ class FederationFactory {
|
|
|
1659
1677
|
lastData = (0, utils_6.getOrThrowError)(this.parentDefinitionDataByTypeName, fieldData.namedTypeName, string_constants_2.PARENT_DEFINITION_DATA);
|
|
1660
1678
|
}
|
|
1661
1679
|
if (!(0, utils_5.isLeafKind)(lastData.kind)) {
|
|
1662
|
-
fieldErrorMessages.push((0, errors_1.nonLeafSubscriptionFieldConditionFieldPathFinalFieldErrorMessage)(inputFieldPath, conditionFieldPath, paths[paths.length - 1], (0, utils_6.
|
|
1680
|
+
fieldErrorMessages.push((0, errors_1.nonLeafSubscriptionFieldConditionFieldPathFinalFieldErrorMessage)(inputFieldPath, conditionFieldPath, paths[paths.length - 1], (0, utils_6.kindToNodeType)(lastData.kind), lastData.name));
|
|
1663
1681
|
return [];
|
|
1664
1682
|
}
|
|
1665
1683
|
return paths;
|
|
@@ -1689,7 +1707,7 @@ class FederationFactory {
|
|
|
1689
1707
|
break;
|
|
1690
1708
|
}
|
|
1691
1709
|
if (objectFieldNode.value.kind !== graphql_1.Kind.STRING) {
|
|
1692
|
-
fieldErrorMessages.push((0, errors_1.invalidInputFieldTypeErrorMessage)(inputFieldPath, string_constants_2.STRING, (0, utils_6.
|
|
1710
|
+
fieldErrorMessages.push((0, errors_1.invalidInputFieldTypeErrorMessage)(inputFieldPath, string_constants_2.STRING, (0, utils_6.kindToNodeType)(objectFieldNode.value.kind)));
|
|
1693
1711
|
hasErrors = true;
|
|
1694
1712
|
break;
|
|
1695
1713
|
}
|
|
@@ -1712,7 +1730,7 @@ class FederationFactory {
|
|
|
1712
1730
|
}
|
|
1713
1731
|
const objectFieldValueKind = objectFieldNode.value.kind;
|
|
1714
1732
|
if (objectFieldValueKind == graphql_1.Kind.NULL || objectFieldValueKind == graphql_1.Kind.OBJECT) {
|
|
1715
|
-
fieldErrorMessages.push((0, errors_1.invalidInputFieldTypeErrorMessage)(inputFieldPath, string_constants_2.LIST, (0, utils_6.
|
|
1733
|
+
fieldErrorMessages.push((0, errors_1.invalidInputFieldTypeErrorMessage)(inputFieldPath, string_constants_2.LIST, (0, utils_6.kindToNodeType)(objectFieldNode.value.kind)));
|
|
1716
1734
|
hasErrors = true;
|
|
1717
1735
|
break;
|
|
1718
1736
|
}
|
|
@@ -1836,7 +1854,7 @@ class FederationFactory {
|
|
|
1836
1854
|
}
|
|
1837
1855
|
default: {
|
|
1838
1856
|
const expectedTypeString = string_constants_1.SUBSCRIPTION_FILTER_LIST_INPUT_NAMES.has(fieldName) ? string_constants_2.LIST : string_constants_2.OBJECT;
|
|
1839
|
-
errorMessages.push((0, errors_1.subscriptionFilterConditionInvalidInputFieldTypeErrorMessage)(inputFieldPath, expectedTypeString, (0, utils_6.
|
|
1857
|
+
errorMessages.push((0, errors_1.subscriptionFilterConditionInvalidInputFieldTypeErrorMessage)(inputFieldPath, expectedTypeString, (0, utils_6.kindToNodeType)(objectFieldNode.value.kind)));
|
|
1840
1858
|
return false;
|
|
1841
1859
|
}
|
|
1842
1860
|
}
|
|
@@ -1849,7 +1867,7 @@ class FederationFactory {
|
|
|
1849
1867
|
const argumentNode = directiveNode.arguments[0];
|
|
1850
1868
|
if (argumentNode.value.kind !== graphql_1.Kind.OBJECT) {
|
|
1851
1869
|
this.errors.push((0, errors_1.invalidSubscriptionFilterDirectiveError)(fieldPath, [
|
|
1852
|
-
(0, errors_1.subscriptionFilterConditionInvalidInputFieldTypeErrorMessage)(string_constants_2.CONDITION, string_constants_2.OBJECT, (0, utils_6.
|
|
1870
|
+
(0, errors_1.subscriptionFilterConditionInvalidInputFieldTypeErrorMessage)(string_constants_2.CONDITION, string_constants_2.OBJECT, (0, utils_6.kindToNodeType)(argumentNode.value.kind)),
|
|
1853
1871
|
]));
|
|
1854
1872
|
return;
|
|
1855
1873
|
}
|
|
@@ -2047,12 +2065,12 @@ class FederationFactory {
|
|
|
2047
2065
|
this.handleChildTagExclusions(parentDefinitionData, parentDefinitionData.enumValueDataByValueName, parentTagData.childTagDataByChildName, contractTagOptions.tagNamesToExclude);
|
|
2048
2066
|
break;
|
|
2049
2067
|
case graphql_1.Kind.INPUT_OBJECT_TYPE_DEFINITION:
|
|
2050
|
-
this.handleChildTagExclusions(parentDefinitionData, parentDefinitionData.
|
|
2068
|
+
this.handleChildTagExclusions(parentDefinitionData, parentDefinitionData.inputValueDataByName, parentTagData.childTagDataByChildName, contractTagOptions.tagNamesToExclude);
|
|
2051
2069
|
break;
|
|
2052
2070
|
default:
|
|
2053
|
-
let accessibleFields = parentDefinitionData.
|
|
2071
|
+
let accessibleFields = parentDefinitionData.fieldDataByName.size;
|
|
2054
2072
|
for (const [fieldName, childTagData] of parentTagData.childTagDataByChildName) {
|
|
2055
|
-
const fieldData = (0, utils_6.getOrThrowError)(parentDefinitionData.
|
|
2073
|
+
const fieldData = (0, utils_6.getOrThrowError)(parentDefinitionData.fieldDataByName, fieldName, `${parentTypeName}.fieldDataByFieldName`);
|
|
2056
2074
|
if ((0, utils_5.isNodeDataInaccessible)(fieldData)) {
|
|
2057
2075
|
accessibleFields -= 1;
|
|
2058
2076
|
continue;
|
|
@@ -2066,7 +2084,7 @@ class FederationFactory {
|
|
|
2066
2084
|
continue;
|
|
2067
2085
|
}
|
|
2068
2086
|
for (const [argumentName, tagNames] of childTagData.tagNamesByArgumentName) {
|
|
2069
|
-
const inputValueData = (0, utils_6.getOrThrowError)(fieldData.
|
|
2087
|
+
const inputValueData = (0, utils_6.getOrThrowError)(fieldData.argumentDataByName, argumentName, `${fieldName}.argumentDataByArgumentName`);
|
|
2070
2088
|
if ((0, utils_5.isNodeDataInaccessible)(inputValueData)) {
|
|
2071
2089
|
continue;
|
|
2072
2090
|
}
|
|
@@ -2119,11 +2137,11 @@ class FederationFactory {
|
|
|
2119
2137
|
this.handleChildTagInclusions(parentDefinitionData, parentDefinitionData.enumValueDataByValueName, parentTagData.childTagDataByChildName, contractTagOptions.tagNamesToInclude);
|
|
2120
2138
|
break;
|
|
2121
2139
|
case graphql_1.Kind.INPUT_OBJECT_TYPE_DEFINITION:
|
|
2122
|
-
this.handleChildTagInclusions(parentDefinitionData, parentDefinitionData.
|
|
2140
|
+
this.handleChildTagInclusions(parentDefinitionData, parentDefinitionData.inputValueDataByName, parentTagData.childTagDataByChildName, contractTagOptions.tagNamesToInclude);
|
|
2123
2141
|
break;
|
|
2124
2142
|
default:
|
|
2125
|
-
let accessibleFields = parentDefinitionData.
|
|
2126
|
-
for (const [fieldName, fieldData] of parentDefinitionData.
|
|
2143
|
+
let accessibleFields = parentDefinitionData.fieldDataByName.size;
|
|
2144
|
+
for (const [fieldName, fieldData] of parentDefinitionData.fieldDataByName) {
|
|
2127
2145
|
if ((0, utils_5.isNodeDataInaccessible)(fieldData)) {
|
|
2128
2146
|
accessibleFields -= 1;
|
|
2129
2147
|
continue;
|