@wundergraph/composition 0.39.2 → 0.41.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/router-configuration/types.d.ts +9 -1
- package/dist/schema-building/types.d.ts +7 -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 +9 -0
- package/dist/utils/string-constants.js +23 -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 +4 -5
- package/dist/v1/federation/federation-factory.js +65 -63
- 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/directive-definition-data.d.ts +2 -0
- package/dist/v1/normalization/directive-definition-data.js +63 -1
- package/dist/v1/normalization/directive-definition-data.js.map +1 -1
- package/dist/v1/normalization/normalization-factory.d.ts +5 -5
- package/dist/v1/normalization/normalization-factory.js +258 -157
- package/dist/v1/normalization/normalization-factory.js.map +1 -1
- package/dist/v1/normalization/types.d.ts +1 -6
- package/dist/v1/normalization/utils.js +10 -8
- package/dist/v1/normalization/utils.js.map +1 -1
- package/dist/v1/normalization/walkers.js +8 -8
- 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/utils/constants.d.ts +2 -0
- package/dist/v1/utils/constants.js +59 -1
- package/dist/v1/utils/constants.js.map +1 -1
- package/dist/v1/utils/string-constants.js +2 -0
- package/dist/v1/utils/string-constants.js.map +1 -1
- package/package.json +2 -2
- package/dist/errors/utils.d.ts +0 -4
- package/dist/errors/utils.js.map +0 -1
|
@@ -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);
|
|
@@ -581,6 +581,7 @@ class FederationFactory {
|
|
|
581
581
|
isArgument: sourceData.isArgument,
|
|
582
582
|
kind: sourceData.kind,
|
|
583
583
|
name: sourceData.name,
|
|
584
|
+
namedTypeKind: sourceData.namedTypeKind,
|
|
584
585
|
namedTypeName: sourceData.namedTypeName,
|
|
585
586
|
node: {
|
|
586
587
|
directives: [],
|
|
@@ -613,7 +614,7 @@ class FederationFactory {
|
|
|
613
614
|
}
|
|
614
615
|
copyFieldData(sourceData, isInaccessible) {
|
|
615
616
|
return {
|
|
616
|
-
|
|
617
|
+
argumentDataByName: this.copyInputValueDataByValueName(sourceData.argumentDataByName, isInaccessible, sourceData.federatedCoords),
|
|
617
618
|
configureDescriptionDataBySubgraphName: (0, utils_6.copyObjectValueMap)(sourceData.configureDescriptionDataBySubgraphName),
|
|
618
619
|
directivesByDirectiveName: (0, utils_6.copyArrayValueMap)(sourceData.directivesByDirectiveName),
|
|
619
620
|
externalFieldDataBySubgraphName: (0, utils_6.copyObjectValueMap)(sourceData.externalFieldDataBySubgraphName),
|
|
@@ -622,6 +623,7 @@ class FederationFactory {
|
|
|
622
623
|
isShareableBySubgraphName: new Map(sourceData.isShareableBySubgraphName),
|
|
623
624
|
kind: sourceData.kind,
|
|
624
625
|
name: sourceData.name,
|
|
626
|
+
namedTypeKind: sourceData.namedTypeKind,
|
|
625
627
|
namedTypeName: sourceData.namedTypeName,
|
|
626
628
|
node: {
|
|
627
629
|
arguments: [],
|
|
@@ -650,7 +652,7 @@ class FederationFactory {
|
|
|
650
652
|
}
|
|
651
653
|
return output;
|
|
652
654
|
}
|
|
653
|
-
|
|
655
|
+
copyFieldDataByName(source, isParentInaccessible) {
|
|
654
656
|
const fieldDataByFieldName = new Map();
|
|
655
657
|
for (const [fieldName, sourceData] of source) {
|
|
656
658
|
const isFieldInaccessible = isParentInaccessible || (0, utils_5.isNodeDataInaccessible)(sourceData);
|
|
@@ -686,7 +688,7 @@ class FederationFactory {
|
|
|
686
688
|
case graphql_1.Kind.INPUT_OBJECT_TYPE_DEFINITION: {
|
|
687
689
|
return {
|
|
688
690
|
...data,
|
|
689
|
-
|
|
691
|
+
inputValueDataByName: this.copyInputValueDataByValueName(sourceData.inputValueDataByName, sourceData.isInaccessible, sourceData.name),
|
|
690
692
|
isInaccessible: sourceData.isInaccessible,
|
|
691
693
|
kind: sourceData.kind,
|
|
692
694
|
node: {
|
|
@@ -699,7 +701,7 @@ class FederationFactory {
|
|
|
699
701
|
case graphql_1.Kind.INTERFACE_TYPE_DEFINITION: {
|
|
700
702
|
return {
|
|
701
703
|
...data,
|
|
702
|
-
|
|
704
|
+
fieldDataByName: this.copyFieldDataByName(sourceData.fieldDataByName, sourceData.isInaccessible),
|
|
703
705
|
implementedInterfaceTypeNames: new Set(sourceData.implementedInterfaceTypeNames),
|
|
704
706
|
isEntity: sourceData.isEntity,
|
|
705
707
|
isInaccessible: sourceData.isInaccessible,
|
|
@@ -714,7 +716,7 @@ class FederationFactory {
|
|
|
714
716
|
case graphql_1.Kind.OBJECT_TYPE_DEFINITION: {
|
|
715
717
|
return {
|
|
716
718
|
...data,
|
|
717
|
-
|
|
719
|
+
fieldDataByName: this.copyFieldDataByName(sourceData.fieldDataByName, sourceData.isInaccessible),
|
|
718
720
|
implementedInterfaceTypeNames: new Set(sourceData.implementedInterfaceTypeNames),
|
|
719
721
|
isEntity: sourceData.isEntity,
|
|
720
722
|
isInaccessible: sourceData.isInaccessible,
|
|
@@ -786,7 +788,7 @@ class FederationFactory {
|
|
|
786
788
|
!entityInterfaceData.interfaceObjectSubgraphs.has(subgraphName) ||
|
|
787
789
|
targetData.kind !== graphql_1.Kind.INTERFACE_TYPE_DEFINITION ||
|
|
788
790
|
incomingData.kind !== graphql_1.Kind.OBJECT_TYPE_DEFINITION) {
|
|
789
|
-
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)));
|
|
790
792
|
return;
|
|
791
793
|
}
|
|
792
794
|
}
|
|
@@ -815,8 +817,8 @@ class FederationFactory {
|
|
|
815
817
|
}
|
|
816
818
|
targetData.isInaccessible ||= isParentInaccessible;
|
|
817
819
|
(0, utils_6.addIterableValuesToSet)(incomingData.subgraphNames, targetData.subgraphNames);
|
|
818
|
-
for (const inputValueData of incomingData.
|
|
819
|
-
this.upsertInputValueData(targetData.
|
|
820
|
+
for (const inputValueData of incomingData.inputValueDataByName.values()) {
|
|
821
|
+
this.upsertInputValueData(targetData.inputValueDataByName, inputValueData, targetData.name, targetData.isInaccessible);
|
|
820
822
|
}
|
|
821
823
|
return;
|
|
822
824
|
case graphql_1.Kind.INTERFACE_TYPE_DEFINITION:
|
|
@@ -831,8 +833,8 @@ class FederationFactory {
|
|
|
831
833
|
targetData.isInaccessible ||= isParentInaccessible;
|
|
832
834
|
(0, utils_6.addIterableValuesToSet)(compositeOutputData.implementedInterfaceTypeNames, targetData.implementedInterfaceTypeNames);
|
|
833
835
|
(0, utils_6.addIterableValuesToSet)(compositeOutputData.subgraphNames, targetData.subgraphNames);
|
|
834
|
-
for (const fieldData of compositeOutputData.
|
|
835
|
-
this.upsertFieldData(targetData.
|
|
836
|
+
for (const fieldData of compositeOutputData.fieldDataByName.values()) {
|
|
837
|
+
this.upsertFieldData(targetData.fieldDataByName, fieldData, targetData.isInaccessible);
|
|
836
838
|
}
|
|
837
839
|
return;
|
|
838
840
|
case graphql_1.Kind.UNION_TYPE_DEFINITION:
|
|
@@ -851,14 +853,14 @@ class FederationFactory {
|
|
|
851
853
|
propagateInaccessibilityToExistingChildren(data) {
|
|
852
854
|
switch (data.kind) {
|
|
853
855
|
case graphql_1.Kind.INPUT_OBJECT_TYPE_DEFINITION:
|
|
854
|
-
for (const inputFieldData of data.
|
|
856
|
+
for (const inputFieldData of data.inputValueDataByName.values()) {
|
|
855
857
|
this.inaccessibleCoords.add(inputFieldData.federatedCoords);
|
|
856
858
|
}
|
|
857
859
|
break;
|
|
858
860
|
default:
|
|
859
|
-
for (const fieldData of data.
|
|
861
|
+
for (const fieldData of data.fieldDataByName.values()) {
|
|
860
862
|
this.inaccessibleCoords.add(fieldData.federatedCoords);
|
|
861
|
-
for (const inputValueData of fieldData.
|
|
863
|
+
for (const inputValueData of fieldData.argumentDataByName.values()) {
|
|
862
864
|
this.inaccessibleCoords.add(inputValueData.federatedCoords);
|
|
863
865
|
}
|
|
864
866
|
}
|
|
@@ -945,10 +947,10 @@ class FederationFactory {
|
|
|
945
947
|
// This error should never happen
|
|
946
948
|
if (compositeOutputData.kind !== graphql_1.Kind.INTERFACE_TYPE_DEFINITION &&
|
|
947
949
|
compositeOutputData.kind !== graphql_1.Kind.OBJECT_TYPE_DEFINITION) {
|
|
948
|
-
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)));
|
|
949
951
|
continue;
|
|
950
952
|
}
|
|
951
|
-
const fieldData = compositeOutputData.
|
|
953
|
+
const fieldData = compositeOutputData.fieldDataByName.get(coordinates[1]);
|
|
952
954
|
// This error should never happen
|
|
953
955
|
if (!fieldData) {
|
|
954
956
|
this.errors.push((0, errors_1.unknownFieldDataError)(fieldCoordinates));
|
|
@@ -1161,7 +1163,7 @@ class FederationFactory {
|
|
|
1161
1163
|
const interfaceAuthData = this.authorizationDataByParentTypeName.get(entityInterfaceTypeName);
|
|
1162
1164
|
for (const fieldName of entityInterfaceData.interfaceObjectFieldNames) {
|
|
1163
1165
|
const fieldCoords = `${concreteTypeName}.${fieldName}`;
|
|
1164
|
-
const interfaceFieldData = (0, utils_6.getOrThrowError)(entityInterface.
|
|
1166
|
+
const interfaceFieldData = (0, utils_6.getOrThrowError)(entityInterface.fieldDataByName, fieldName, `${entityInterfaceTypeName}.fieldDataByFieldName`);
|
|
1165
1167
|
(0, utils_6.getValueOrDefault)(this.fieldCoordsByNamedTypeName, interfaceFieldData.namedTypeName, () => new Set()).add(fieldCoords);
|
|
1166
1168
|
const interfaceFieldAuthData = interfaceAuthData?.fieldAuthDataByFieldName.get(fieldName);
|
|
1167
1169
|
if (interfaceFieldAuthData) {
|
|
@@ -1170,13 +1172,13 @@ class FederationFactory {
|
|
|
1170
1172
|
this.invalidORScopesCoords.add(fieldCoords);
|
|
1171
1173
|
}
|
|
1172
1174
|
}
|
|
1173
|
-
const existingFieldData = concreteTypeData.
|
|
1175
|
+
const existingFieldData = concreteTypeData.fieldDataByName.get(fieldName);
|
|
1174
1176
|
if (existingFieldData) {
|
|
1175
1177
|
// TODO handle shareability
|
|
1176
1178
|
continue;
|
|
1177
1179
|
}
|
|
1178
1180
|
const isInaccessible = entityInterface.isInaccessible || concreteTypeData.isInaccessible || interfaceFieldData.isInaccessible;
|
|
1179
|
-
concreteTypeData.
|
|
1181
|
+
concreteTypeData.fieldDataByName.set(fieldName, this.copyFieldData(interfaceFieldData, isInaccessible));
|
|
1180
1182
|
}
|
|
1181
1183
|
this.handleInterfaceObjectForInternalGraph({
|
|
1182
1184
|
internalSubgraph,
|
|
@@ -1268,7 +1270,7 @@ class FederationFactory {
|
|
|
1268
1270
|
const argumentNames = [];
|
|
1269
1271
|
const invalidRequiredArguments = [];
|
|
1270
1272
|
const fieldPath = `${fieldData.renamedParentTypeName}.${fieldData.name}`;
|
|
1271
|
-
for (const [argumentName, inputValueData] of fieldData.
|
|
1273
|
+
for (const [argumentName, inputValueData] of fieldData.argumentDataByName) {
|
|
1272
1274
|
if (fieldData.subgraphNames.size === inputValueData.subgraphNames.size) {
|
|
1273
1275
|
argumentNames.push(argumentName);
|
|
1274
1276
|
argumentNodes.push(this.getNodeWithPersistedDirectivesByInputValueData(inputValueData));
|
|
@@ -1305,7 +1307,7 @@ class FederationFactory {
|
|
|
1305
1307
|
pushParentDefinitionDataToDocumentDefinitions(interfaceImplementations) {
|
|
1306
1308
|
for (const [parentTypeName, parentDefinitionData] of this.parentDefinitionDataByTypeName) {
|
|
1307
1309
|
if (parentDefinitionData.extensionType !== types_1.ExtensionType.NONE) {
|
|
1308
|
-
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));
|
|
1309
1311
|
}
|
|
1310
1312
|
switch (parentDefinitionData.kind) {
|
|
1311
1313
|
case graphql_1.Kind.ENUM_TYPE_DEFINITION:
|
|
@@ -1354,7 +1356,7 @@ class FederationFactory {
|
|
|
1354
1356
|
break;
|
|
1355
1357
|
}
|
|
1356
1358
|
if (clientEnumValueNodes.length < 1) {
|
|
1357
|
-
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));
|
|
1358
1360
|
break;
|
|
1359
1361
|
}
|
|
1360
1362
|
this.clientDefinitions.push({
|
|
@@ -1367,7 +1369,7 @@ class FederationFactory {
|
|
|
1367
1369
|
const invalidRequiredInputs = [];
|
|
1368
1370
|
const inputValueNodes = [];
|
|
1369
1371
|
const clientInputValueNodes = [];
|
|
1370
|
-
for (const [inputValueName, inputValueData] of parentDefinitionData.
|
|
1372
|
+
for (const [inputValueName, inputValueData] of parentDefinitionData.inputValueDataByName) {
|
|
1371
1373
|
if (parentDefinitionData.subgraphNames.size === inputValueData.subgraphNames.size) {
|
|
1372
1374
|
inputValueNodes.push(this.getNodeWithPersistedDirectivesByInputValueData(inputValueData));
|
|
1373
1375
|
if ((0, utils_5.isNodeDataInaccessible)(inputValueData)) {
|
|
@@ -1397,7 +1399,7 @@ class FederationFactory {
|
|
|
1397
1399
|
break;
|
|
1398
1400
|
}
|
|
1399
1401
|
if (clientInputValueNodes.length < 1) {
|
|
1400
|
-
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'));
|
|
1401
1403
|
break;
|
|
1402
1404
|
}
|
|
1403
1405
|
this.clientDefinitions.push({
|
|
@@ -1416,7 +1418,7 @@ class FederationFactory {
|
|
|
1416
1418
|
const isObject = parentDefinitionData.kind === graphql_1.Kind.OBJECT_TYPE_DEFINITION;
|
|
1417
1419
|
const authData = this.authorizationDataByParentTypeName.get(parentTypeName);
|
|
1418
1420
|
(0, utils_5.propagateAuthDirectives)(parentDefinitionData, authData);
|
|
1419
|
-
for (const [fieldName, fieldData] of parentDefinitionData.
|
|
1421
|
+
for (const [fieldName, fieldData] of parentDefinitionData.fieldDataByName) {
|
|
1420
1422
|
(0, utils_5.propagateFieldAuthDirectives)(fieldData, authData);
|
|
1421
1423
|
const argumentNodes = this.getValidFieldArgumentNodes(fieldData);
|
|
1422
1424
|
if (isObject) {
|
|
@@ -1458,7 +1460,7 @@ class FederationFactory {
|
|
|
1458
1460
|
if (clientSchemaFieldNodes.length < 1) {
|
|
1459
1461
|
const error = isQuery
|
|
1460
1462
|
? (0, errors_1.noQueryRootTypeError)(false)
|
|
1461
|
-
: (0, errors_1.allChildDefinitionsAreInaccessibleError)((0, utils_6.
|
|
1463
|
+
: (0, errors_1.allChildDefinitionsAreInaccessibleError)((0, utils_6.kindToNodeType)(parentDefinitionData.kind), parentTypeName, string_constants_2.FIELD);
|
|
1462
1464
|
this.errors.push(error);
|
|
1463
1465
|
break;
|
|
1464
1466
|
}
|
|
@@ -1619,16 +1621,16 @@ class FederationFactory {
|
|
|
1619
1621
|
}
|
|
1620
1622
|
}
|
|
1621
1623
|
if (invalidCoords.length > 0) {
|
|
1622
|
-
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));
|
|
1623
1625
|
}
|
|
1624
1626
|
}
|
|
1625
1627
|
validateQueryRootType() {
|
|
1626
1628
|
const query = this.parentDefinitionDataByTypeName.get(string_constants_2.QUERY);
|
|
1627
|
-
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) {
|
|
1628
1630
|
this.errors.push((0, errors_1.noQueryRootTypeError)());
|
|
1629
1631
|
return;
|
|
1630
1632
|
}
|
|
1631
|
-
for (const fieldData of query.
|
|
1633
|
+
for (const fieldData of query.fieldDataByName.values()) {
|
|
1632
1634
|
if (!(0, utils_5.isNodeDataInaccessible)(fieldData)) {
|
|
1633
1635
|
return;
|
|
1634
1636
|
}
|
|
@@ -1654,7 +1656,7 @@ class FederationFactory {
|
|
|
1654
1656
|
fieldErrorMessages.push((0, errors_1.invalidSubscriptionFieldConditionFieldPathParentErrorMessage)(inputFieldPath, conditionFieldPath, partialConditionFieldPath));
|
|
1655
1657
|
return [];
|
|
1656
1658
|
}
|
|
1657
|
-
const fieldData = lastData.
|
|
1659
|
+
const fieldData = lastData.fieldDataByName.get(fieldName);
|
|
1658
1660
|
if (!fieldData) {
|
|
1659
1661
|
fieldErrorMessages.push((0, errors_1.undefinedSubscriptionFieldConditionFieldPathFieldErrorMessage)(inputFieldPath, conditionFieldPath, partialConditionFieldPath, fieldName, lastData.renamedTypeName));
|
|
1660
1662
|
return [];
|
|
@@ -1675,7 +1677,7 @@ class FederationFactory {
|
|
|
1675
1677
|
lastData = (0, utils_6.getOrThrowError)(this.parentDefinitionDataByTypeName, fieldData.namedTypeName, string_constants_2.PARENT_DEFINITION_DATA);
|
|
1676
1678
|
}
|
|
1677
1679
|
if (!(0, utils_5.isLeafKind)(lastData.kind)) {
|
|
1678
|
-
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));
|
|
1679
1681
|
return [];
|
|
1680
1682
|
}
|
|
1681
1683
|
return paths;
|
|
@@ -1705,7 +1707,7 @@ class FederationFactory {
|
|
|
1705
1707
|
break;
|
|
1706
1708
|
}
|
|
1707
1709
|
if (objectFieldNode.value.kind !== graphql_1.Kind.STRING) {
|
|
1708
|
-
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)));
|
|
1709
1711
|
hasErrors = true;
|
|
1710
1712
|
break;
|
|
1711
1713
|
}
|
|
@@ -1728,7 +1730,7 @@ class FederationFactory {
|
|
|
1728
1730
|
}
|
|
1729
1731
|
const objectFieldValueKind = objectFieldNode.value.kind;
|
|
1730
1732
|
if (objectFieldValueKind == graphql_1.Kind.NULL || objectFieldValueKind == graphql_1.Kind.OBJECT) {
|
|
1731
|
-
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)));
|
|
1732
1734
|
hasErrors = true;
|
|
1733
1735
|
break;
|
|
1734
1736
|
}
|
|
@@ -1852,7 +1854,7 @@ class FederationFactory {
|
|
|
1852
1854
|
}
|
|
1853
1855
|
default: {
|
|
1854
1856
|
const expectedTypeString = string_constants_1.SUBSCRIPTION_FILTER_LIST_INPUT_NAMES.has(fieldName) ? string_constants_2.LIST : string_constants_2.OBJECT;
|
|
1855
|
-
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)));
|
|
1856
1858
|
return false;
|
|
1857
1859
|
}
|
|
1858
1860
|
}
|
|
@@ -1865,7 +1867,7 @@ class FederationFactory {
|
|
|
1865
1867
|
const argumentNode = directiveNode.arguments[0];
|
|
1866
1868
|
if (argumentNode.value.kind !== graphql_1.Kind.OBJECT) {
|
|
1867
1869
|
this.errors.push((0, errors_1.invalidSubscriptionFilterDirectiveError)(fieldPath, [
|
|
1868
|
-
(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)),
|
|
1869
1871
|
]));
|
|
1870
1872
|
return;
|
|
1871
1873
|
}
|
|
@@ -2063,12 +2065,12 @@ class FederationFactory {
|
|
|
2063
2065
|
this.handleChildTagExclusions(parentDefinitionData, parentDefinitionData.enumValueDataByValueName, parentTagData.childTagDataByChildName, contractTagOptions.tagNamesToExclude);
|
|
2064
2066
|
break;
|
|
2065
2067
|
case graphql_1.Kind.INPUT_OBJECT_TYPE_DEFINITION:
|
|
2066
|
-
this.handleChildTagExclusions(parentDefinitionData, parentDefinitionData.
|
|
2068
|
+
this.handleChildTagExclusions(parentDefinitionData, parentDefinitionData.inputValueDataByName, parentTagData.childTagDataByChildName, contractTagOptions.tagNamesToExclude);
|
|
2067
2069
|
break;
|
|
2068
2070
|
default:
|
|
2069
|
-
let accessibleFields = parentDefinitionData.
|
|
2071
|
+
let accessibleFields = parentDefinitionData.fieldDataByName.size;
|
|
2070
2072
|
for (const [fieldName, childTagData] of parentTagData.childTagDataByChildName) {
|
|
2071
|
-
const fieldData = (0, utils_6.getOrThrowError)(parentDefinitionData.
|
|
2073
|
+
const fieldData = (0, utils_6.getOrThrowError)(parentDefinitionData.fieldDataByName, fieldName, `${parentTypeName}.fieldDataByFieldName`);
|
|
2072
2074
|
if ((0, utils_5.isNodeDataInaccessible)(fieldData)) {
|
|
2073
2075
|
accessibleFields -= 1;
|
|
2074
2076
|
continue;
|
|
@@ -2082,7 +2084,7 @@ class FederationFactory {
|
|
|
2082
2084
|
continue;
|
|
2083
2085
|
}
|
|
2084
2086
|
for (const [argumentName, tagNames] of childTagData.tagNamesByArgumentName) {
|
|
2085
|
-
const inputValueData = (0, utils_6.getOrThrowError)(fieldData.
|
|
2087
|
+
const inputValueData = (0, utils_6.getOrThrowError)(fieldData.argumentDataByName, argumentName, `${fieldName}.argumentDataByArgumentName`);
|
|
2086
2088
|
if ((0, utils_5.isNodeDataInaccessible)(inputValueData)) {
|
|
2087
2089
|
continue;
|
|
2088
2090
|
}
|
|
@@ -2135,11 +2137,11 @@ class FederationFactory {
|
|
|
2135
2137
|
this.handleChildTagInclusions(parentDefinitionData, parentDefinitionData.enumValueDataByValueName, parentTagData.childTagDataByChildName, contractTagOptions.tagNamesToInclude);
|
|
2136
2138
|
break;
|
|
2137
2139
|
case graphql_1.Kind.INPUT_OBJECT_TYPE_DEFINITION:
|
|
2138
|
-
this.handleChildTagInclusions(parentDefinitionData, parentDefinitionData.
|
|
2140
|
+
this.handleChildTagInclusions(parentDefinitionData, parentDefinitionData.inputValueDataByName, parentTagData.childTagDataByChildName, contractTagOptions.tagNamesToInclude);
|
|
2139
2141
|
break;
|
|
2140
2142
|
default:
|
|
2141
|
-
let accessibleFields = parentDefinitionData.
|
|
2142
|
-
for (const [fieldName, fieldData] of parentDefinitionData.
|
|
2143
|
+
let accessibleFields = parentDefinitionData.fieldDataByName.size;
|
|
2144
|
+
for (const [fieldName, fieldData] of parentDefinitionData.fieldDataByName) {
|
|
2143
2145
|
if ((0, utils_5.isNodeDataInaccessible)(fieldData)) {
|
|
2144
2146
|
accessibleFields -= 1;
|
|
2145
2147
|
continue;
|