@wundergraph/composition 0.38.0 → 0.39.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/normalization/types.d.ts +2 -0
- package/dist/router-configuration/types.d.ts +2 -1
- package/dist/schema-building/types.d.ts +15 -4
- package/dist/schema-building/utils.d.ts +5 -4
- package/dist/schema-building/utils.js +34 -38
- 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 +1 -1
- package/dist/utils/string-constants.js +3 -3
- package/dist/utils/string-constants.js.map +1 -1
- package/dist/utils/utils.d.ts +1 -0
- package/dist/utils/utils.js +8 -0
- package/dist/utils/utils.js.map +1 -1
- package/dist/v1/federation/federation-factory.d.ts +4 -2
- package/dist/v1/federation/federation-factory.js +69 -27
- package/dist/v1/federation/federation-factory.js.map +1 -1
- package/dist/v1/federation/utils.d.ts +1 -0
- package/dist/v1/federation/utils.js.map +1 -1
- package/dist/v1/normalization/normalization-factory.d.ts +6 -8
- package/dist/v1/normalization/normalization-factory.js +48 -147
- package/dist/v1/normalization/normalization-factory.js.map +1 -1
- package/dist/v1/normalization/walkers.d.ts +0 -1
- package/dist/v1/normalization/walkers.js +1 -100
- package/dist/v1/normalization/walkers.js.map +1 -1
- package/dist/v1/utils/constants.d.ts +1 -0
- package/dist/v1/utils/constants.js +2 -1
- package/dist/v1/utils/constants.js.map +1 -1
- package/dist/v1/utils/utils.d.ts +14 -13
- package/dist/v1/utils/utils.js +129 -91
- package/dist/v1/utils/utils.js.map +1 -1
- package/package.json +3 -2
|
@@ -54,8 +54,6 @@ class NormalizationFactory {
|
|
|
54
54
|
entityInterfaceDataByTypeName = new Map();
|
|
55
55
|
eventsConfigurations = new Map();
|
|
56
56
|
fieldSetDataByTypeName = new Map();
|
|
57
|
-
heirFieldAuthorizationDataByTypeName = new Map();
|
|
58
|
-
interfaceTypeNamesWithAuthorizationDirectives = new Set();
|
|
59
57
|
internalGraph;
|
|
60
58
|
invalidConfigureDescriptionNodeDatas = [];
|
|
61
59
|
invalidRepeatedDirectiveNameByCoords = new Map();
|
|
@@ -67,17 +65,18 @@ class NormalizationFactory {
|
|
|
67
65
|
keyFieldSetDatasByTypeName = new Map();
|
|
68
66
|
lastParentNodeKind = graphql_1.Kind.NULL;
|
|
69
67
|
lastChildNodeKind = graphql_1.Kind.NULL;
|
|
70
|
-
|
|
68
|
+
parentTypeNamesWithAuthDirectives = new Set();
|
|
71
69
|
keyFieldSetDataByTypeName = new Map();
|
|
72
70
|
keyFieldSetsByEntityTypeNameByFieldCoords = new Map();
|
|
73
71
|
keyFieldNamesByParentTypeName = new Map();
|
|
72
|
+
fieldCoordsByNamedTypeName = new Map();
|
|
74
73
|
operationTypeNodeByTypeName = new Map();
|
|
75
74
|
originalParentTypeName = '';
|
|
76
75
|
originalTypeNameByRenamedTypeName = new Map();
|
|
77
76
|
parentDefinitionDataByTypeName = new Map();
|
|
78
77
|
parentsWithChildArguments = new Set();
|
|
79
78
|
overridesByTargetSubgraphName = new Map();
|
|
80
|
-
|
|
79
|
+
invalidORScopesCoords = new Set();
|
|
81
80
|
schemaData;
|
|
82
81
|
referencedDirectiveNames = new Set();
|
|
83
82
|
referencedTypeNames = new Set();
|
|
@@ -138,83 +137,6 @@ class NormalizationFactory {
|
|
|
138
137
|
this.errors.push((0, errors_1.invalidArgumentsError)(fieldPath, invalidArguments));
|
|
139
138
|
}
|
|
140
139
|
}
|
|
141
|
-
// Note that directive validation errors are handled elsewhere
|
|
142
|
-
getAuthorizationData(node) {
|
|
143
|
-
const parentTypeName = this.renamedParentTypeName || this.originalParentTypeName;
|
|
144
|
-
let authorizationData = this.authorizationDataByParentTypeName.get(parentTypeName);
|
|
145
|
-
(0, utils_3.resetAuthorizationData)(authorizationData);
|
|
146
|
-
if (!node.directives) {
|
|
147
|
-
return authorizationData;
|
|
148
|
-
}
|
|
149
|
-
let requiresAuthentication = false;
|
|
150
|
-
const requiresScopes = [];
|
|
151
|
-
for (const directiveNode of node.directives) {
|
|
152
|
-
const directiveName = directiveNode.name.value;
|
|
153
|
-
if (directiveName === string_constants_2.AUTHENTICATED) {
|
|
154
|
-
// @authenticated is not repeatable
|
|
155
|
-
if (requiresAuthentication) {
|
|
156
|
-
return;
|
|
157
|
-
}
|
|
158
|
-
requiresAuthentication = true;
|
|
159
|
-
continue;
|
|
160
|
-
}
|
|
161
|
-
if (directiveName !== string_constants_2.REQUIRES_SCOPES) {
|
|
162
|
-
continue;
|
|
163
|
-
}
|
|
164
|
-
// @requiresScopes is not repeatable
|
|
165
|
-
if (requiresScopes.length > 0) {
|
|
166
|
-
return;
|
|
167
|
-
}
|
|
168
|
-
requiresScopes.push(directiveNode);
|
|
169
|
-
}
|
|
170
|
-
if (!requiresAuthentication && requiresScopes.length < 1) {
|
|
171
|
-
return authorizationData;
|
|
172
|
-
}
|
|
173
|
-
if ((0, utils_3.isNodeKindInterface)(node.kind)) {
|
|
174
|
-
this.interfaceTypeNamesWithAuthorizationDirectives.add(parentTypeName);
|
|
175
|
-
}
|
|
176
|
-
if (!authorizationData) {
|
|
177
|
-
authorizationData = (0, utils_3.setAndGetValue)(this.authorizationDataByParentTypeName, this.renamedParentTypeName || this.originalParentTypeName, (0, utils_3.newAuthorizationData)(parentTypeName));
|
|
178
|
-
}
|
|
179
|
-
authorizationData.hasParentLevelAuthorization = true;
|
|
180
|
-
authorizationData.requiresAuthentication = requiresAuthentication;
|
|
181
|
-
if (requiresScopes.length !== 1) {
|
|
182
|
-
return authorizationData;
|
|
183
|
-
}
|
|
184
|
-
const directiveNode = requiresScopes[0];
|
|
185
|
-
if (!directiveNode.arguments || directiveNode.arguments.length !== 1) {
|
|
186
|
-
return;
|
|
187
|
-
}
|
|
188
|
-
const scopesArgument = directiveNode.arguments[0];
|
|
189
|
-
// @TODO list coercion
|
|
190
|
-
if (scopesArgument.name.value !== string_constants_2.SCOPES || scopesArgument.value.kind !== graphql_1.Kind.LIST) {
|
|
191
|
-
return;
|
|
192
|
-
}
|
|
193
|
-
const orScopes = scopesArgument.value.values;
|
|
194
|
-
if (orScopes.length < 1) {
|
|
195
|
-
return authorizationData;
|
|
196
|
-
}
|
|
197
|
-
if (orScopes.length > utils_3.maxOrScopes) {
|
|
198
|
-
this.invalidOrScopesHostPaths.add(this.originalParentTypeName);
|
|
199
|
-
return;
|
|
200
|
-
}
|
|
201
|
-
for (const scopes of orScopes) {
|
|
202
|
-
if (scopes.kind !== graphql_1.Kind.LIST) {
|
|
203
|
-
return;
|
|
204
|
-
}
|
|
205
|
-
const andScopes = new Set();
|
|
206
|
-
for (const scope of scopes.values) {
|
|
207
|
-
if (scope.kind !== graphql_1.Kind.STRING) {
|
|
208
|
-
return;
|
|
209
|
-
}
|
|
210
|
-
andScopes.add(scope.value);
|
|
211
|
-
}
|
|
212
|
-
if (andScopes.size) {
|
|
213
|
-
authorizationData.requiredScopes.push(andScopes);
|
|
214
|
-
}
|
|
215
|
-
}
|
|
216
|
-
return authorizationData;
|
|
217
|
-
}
|
|
218
140
|
isTypeNameRootType(typeName) {
|
|
219
141
|
return string_constants_2.ROOT_TYPE_NAMES.has(typeName) || this.operationTypeNodeByTypeName.has(typeName);
|
|
220
142
|
}
|
|
@@ -379,7 +301,7 @@ class NormalizationFactory {
|
|
|
379
301
|
if (!isRequiresScopes || argumentName !== string_constants_2.SCOPES) {
|
|
380
302
|
continue;
|
|
381
303
|
}
|
|
382
|
-
this.
|
|
304
|
+
this.extractRequiredScopes({
|
|
383
305
|
directiveCoords,
|
|
384
306
|
// Casts are safe because invalid arguments would short circuit
|
|
385
307
|
orScopes: argumentNode.value.values,
|
|
@@ -399,17 +321,16 @@ class NormalizationFactory {
|
|
|
399
321
|
if (errorMessages.length > 0 || !isRequiresScopes) {
|
|
400
322
|
return errorMessages;
|
|
401
323
|
}
|
|
402
|
-
|
|
403
|
-
data.kind !== graphql_1.Kind.FIELD_DEFINITION &&
|
|
404
|
-
data.kind !== graphql_1.Kind.SCALAR_TYPE_DEFINITION) {
|
|
405
|
-
return errorMessages;
|
|
406
|
-
}
|
|
324
|
+
const parentAuthorizationData = (0, utils_5.getValueOrDefault)(this.authorizationDataByParentTypeName, parentTypeName, () => (0, utils_3.newAuthorizationData)(parentTypeName));
|
|
407
325
|
if (data.kind !== graphql_1.Kind.FIELD_DEFINITION) {
|
|
408
|
-
this.
|
|
326
|
+
this.parentTypeNamesWithAuthDirectives.add(parentTypeName);
|
|
327
|
+
parentAuthorizationData.requiredScopes.push(...requiredScopes);
|
|
328
|
+
}
|
|
329
|
+
else {
|
|
330
|
+
const fieldAuthData = (0, utils_5.getValueOrDefault)(parentAuthorizationData.fieldAuthDataByFieldName, data.name, () => (0, utils_3.newFieldAuthorizationData)(data.name));
|
|
331
|
+
fieldAuthData.inheritedData.requiredScopes.push(...requiredScopes);
|
|
332
|
+
fieldAuthData.originalData.requiredScopes.push(...requiredScopes);
|
|
409
333
|
}
|
|
410
|
-
const parentAuthorizationData = (0, utils_5.getValueOrDefault)(this.authorizationDataByParentTypeName, parentTypeName, () => (0, utils_3.newAuthorizationData)(parentTypeName));
|
|
411
|
-
const authorizationData = (0, utils_3.getAuthorizationDataToUpdate)(parentAuthorizationData, data.node);
|
|
412
|
-
authorizationData.requiredScopes.push(...requiredScopes);
|
|
413
334
|
return errorMessages;
|
|
414
335
|
}
|
|
415
336
|
validateDirectives(data, directiveCoords) {
|
|
@@ -970,6 +891,7 @@ class NormalizationFactory {
|
|
|
970
891
|
}
|
|
971
892
|
this.setParentDataExtensionType(parentData, extensionType);
|
|
972
893
|
parentData.description ||= (0, utils_1.formatDescription)('description' in node ? node.description : undefined);
|
|
894
|
+
parentData.subgraphNames.add(this.subgraphName);
|
|
973
895
|
this.extractConfigureDescriptionsData(parentData);
|
|
974
896
|
return;
|
|
975
897
|
}
|
|
@@ -981,6 +903,7 @@ class NormalizationFactory {
|
|
|
981
903
|
name: typeName,
|
|
982
904
|
node: (0, ast_1.getMutableScalarNode)(node.name),
|
|
983
905
|
persistedDirectivesData: (0, utils_4.newPersistedDirectivesData)(),
|
|
906
|
+
subgraphNames: new Set([this.subgraphName]),
|
|
984
907
|
description: (0, utils_1.formatDescription)('description' in node ? node.description : undefined),
|
|
985
908
|
};
|
|
986
909
|
this.extractConfigureDescriptionsData(newParentData);
|
|
@@ -1026,6 +949,7 @@ class NormalizationFactory {
|
|
|
1026
949
|
this.setParentDataExtensionType(parentData, extensionType);
|
|
1027
950
|
this.extractUnionMembers(node, parentData.memberByMemberTypeName);
|
|
1028
951
|
parentData.description ||= (0, utils_1.formatDescription)('description' in node ? node.description : undefined);
|
|
952
|
+
parentData.subgraphNames.add(this.subgraphName);
|
|
1029
953
|
this.extractConfigureDescriptionsData(parentData);
|
|
1030
954
|
return;
|
|
1031
955
|
}
|
|
@@ -1038,6 +962,7 @@ class NormalizationFactory {
|
|
|
1038
962
|
name: typeName,
|
|
1039
963
|
node: (0, ast_1.getMutableUnionNode)(node.name),
|
|
1040
964
|
persistedDirectivesData: (0, utils_4.newPersistedDirectivesData)(),
|
|
965
|
+
subgraphNames: new Set([this.subgraphName]),
|
|
1041
966
|
description: (0, utils_1.formatDescription)('description' in node ? node.description : undefined),
|
|
1042
967
|
};
|
|
1043
968
|
this.extractConfigureDescriptionsData(newParentData);
|
|
@@ -1513,16 +1438,16 @@ class NormalizationFactory {
|
|
|
1513
1438
|
}
|
|
1514
1439
|
}
|
|
1515
1440
|
handleAuthenticatedDirective(data, parentTypeName) {
|
|
1516
|
-
|
|
1517
|
-
|
|
1518
|
-
data.
|
|
1519
|
-
|
|
1441
|
+
const parentAuthData = (0, utils_5.getValueOrDefault)(this.authorizationDataByParentTypeName, parentTypeName, () => (0, utils_3.newAuthorizationData)(parentTypeName));
|
|
1442
|
+
if (data.kind === graphql_1.Kind.FIELD_DEFINITION) {
|
|
1443
|
+
const fieldAuthData = (0, utils_5.getValueOrDefault)(parentAuthData.fieldAuthDataByFieldName, data.name, () => (0, utils_3.newFieldAuthorizationData)(data.name));
|
|
1444
|
+
fieldAuthData.inheritedData.requiresAuthentication = true;
|
|
1445
|
+
fieldAuthData.originalData.requiresAuthentication = true;
|
|
1520
1446
|
}
|
|
1521
|
-
|
|
1522
|
-
|
|
1447
|
+
else {
|
|
1448
|
+
parentAuthData.requiresAuthentication = true;
|
|
1449
|
+
this.parentTypeNamesWithAuthDirectives.add(parentTypeName);
|
|
1523
1450
|
}
|
|
1524
|
-
const parentAuthorizationData = (0, utils_5.getValueOrDefault)(this.authorizationDataByParentTypeName, parentTypeName, () => (0, utils_3.newAuthorizationData)(parentTypeName));
|
|
1525
|
-
(0, utils_3.getAuthorizationDataToUpdate)(parentAuthorizationData, data.node).requiresAuthentication = true;
|
|
1526
1451
|
}
|
|
1527
1452
|
handleOverrideDirective({ data, directiveCoords, errorMessages, targetSubgraphName }) {
|
|
1528
1453
|
if (targetSubgraphName === this.subgraphName) {
|
|
@@ -1532,19 +1457,20 @@ class NormalizationFactory {
|
|
|
1532
1457
|
const overrideDataForSubgraph = (0, utils_5.getValueOrDefault)(this.overridesByTargetSubgraphName, targetSubgraphName, () => new Map());
|
|
1533
1458
|
(0, utils_5.getValueOrDefault)(overrideDataForSubgraph, data.renamedParentTypeName, () => new Set()).add(data.name);
|
|
1534
1459
|
}
|
|
1535
|
-
|
|
1536
|
-
if (orScopes.length >
|
|
1537
|
-
this.
|
|
1460
|
+
extractRequiredScopes({ directiveCoords, orScopes, requiredScopes }) {
|
|
1461
|
+
if (orScopes.length > constants_1.MAX_OR_SCOPES) {
|
|
1462
|
+
this.invalidORScopesCoords.add(directiveCoords);
|
|
1538
1463
|
return;
|
|
1539
1464
|
}
|
|
1540
1465
|
for (const scopes of orScopes) {
|
|
1541
|
-
const
|
|
1466
|
+
const newANDScopes = new Set();
|
|
1542
1467
|
for (const scope of scopes.values) {
|
|
1543
|
-
|
|
1468
|
+
newANDScopes.add(scope.value);
|
|
1544
1469
|
}
|
|
1545
|
-
if (
|
|
1546
|
-
|
|
1470
|
+
if (newANDScopes.size < 1) {
|
|
1471
|
+
continue;
|
|
1547
1472
|
}
|
|
1473
|
+
(0, utils_3.addScopes)(requiredScopes, newANDScopes);
|
|
1548
1474
|
}
|
|
1549
1475
|
}
|
|
1550
1476
|
getKafkaPublishConfiguration(directive, argumentDataByArgumentName, fieldName, errorMessages) {
|
|
@@ -2165,19 +2091,19 @@ class NormalizationFactory {
|
|
|
2165
2091
|
getEnumNodeByData(enumDefinitionData) {
|
|
2166
2092
|
enumDefinitionData.node.description = enumDefinitionData.description;
|
|
2167
2093
|
enumDefinitionData.node.directives = this.getValidFlattenedDirectiveArray(enumDefinitionData.directivesByDirectiveName, enumDefinitionData.name);
|
|
2168
|
-
enumDefinitionData.node.values = (0, utils_4.childMapToValueArray)(enumDefinitionData.enumValueDataByValueName
|
|
2094
|
+
enumDefinitionData.node.values = (0, utils_4.childMapToValueArray)(enumDefinitionData.enumValueDataByValueName);
|
|
2169
2095
|
return enumDefinitionData.node;
|
|
2170
2096
|
}
|
|
2171
2097
|
getInputObjectNodeByData(inputObjectDefinitionData) {
|
|
2172
2098
|
inputObjectDefinitionData.node.description = inputObjectDefinitionData.description;
|
|
2173
2099
|
inputObjectDefinitionData.node.directives = this.getValidFlattenedDirectiveArray(inputObjectDefinitionData.directivesByDirectiveName, inputObjectDefinitionData.name);
|
|
2174
|
-
inputObjectDefinitionData.node.fields = (0, utils_4.childMapToValueArray)(inputObjectDefinitionData.inputValueDataByValueName
|
|
2100
|
+
inputObjectDefinitionData.node.fields = (0, utils_4.childMapToValueArray)(inputObjectDefinitionData.inputValueDataByValueName);
|
|
2175
2101
|
return inputObjectDefinitionData.node;
|
|
2176
2102
|
}
|
|
2177
2103
|
getCompositeOutputNodeByData(compositeOutputData) {
|
|
2178
2104
|
compositeOutputData.node.description = compositeOutputData.description;
|
|
2179
2105
|
compositeOutputData.node.directives = this.getValidFlattenedDirectiveArray(compositeOutputData.directivesByDirectiveName, compositeOutputData.name);
|
|
2180
|
-
compositeOutputData.node.fields = (0, utils_4.childMapToValueArray)(compositeOutputData.fieldDataByFieldName
|
|
2106
|
+
compositeOutputData.node.fields = (0, utils_4.childMapToValueArray)(compositeOutputData.fieldDataByFieldName);
|
|
2181
2107
|
compositeOutputData.node.interfaces = (0, utils_1.setToNamedTypeNodeArray)(compositeOutputData.implementedInterfaceTypeNames);
|
|
2182
2108
|
return compositeOutputData.node;
|
|
2183
2109
|
}
|
|
@@ -2384,36 +2310,8 @@ class NormalizationFactory {
|
|
|
2384
2310
|
for (const [parentTypeName, parentData] of this.parentDefinitionDataByTypeName) {
|
|
2385
2311
|
this.validateDirectives(parentData, parentTypeName);
|
|
2386
2312
|
}
|
|
2387
|
-
|
|
2388
|
-
|
|
2389
|
-
const interfaceAuthorizationData = this.authorizationDataByParentTypeName.get(interfaceTypeName);
|
|
2390
|
-
if (!interfaceAuthorizationData) {
|
|
2391
|
-
continue;
|
|
2392
|
-
}
|
|
2393
|
-
const concreteTypeNames = this.concreteTypeNamesByAbstractTypeName.get(interfaceTypeName);
|
|
2394
|
-
for (const concreteTypeName of concreteTypeNames || []) {
|
|
2395
|
-
const concreteAuthorizationData = (0, utils_5.getValueOrDefault)(this.authorizationDataByParentTypeName, concreteTypeName, () => (0, utils_3.newAuthorizationData)(concreteTypeName));
|
|
2396
|
-
for (const [fieldName, interfaceFieldAuthorizationData,] of interfaceAuthorizationData.fieldAuthorizationDataByFieldName) {
|
|
2397
|
-
if (!(0, utils_3.upsertFieldAuthorizationData)(concreteAuthorizationData.fieldAuthorizationDataByFieldName, interfaceFieldAuthorizationData)) {
|
|
2398
|
-
this.invalidOrScopesHostPaths.add(`${concreteTypeName}.${fieldName}`);
|
|
2399
|
-
}
|
|
2400
|
-
}
|
|
2401
|
-
}
|
|
2402
|
-
}
|
|
2403
|
-
// Apply inherited leaf authorization that was not applied to interface fields of that type earlier
|
|
2404
|
-
for (const [typeName, fieldAuthorizationDatas] of this.heirFieldAuthorizationDataByTypeName) {
|
|
2405
|
-
const authorizationData = this.authorizationDataByParentTypeName.get(typeName);
|
|
2406
|
-
if (!authorizationData) {
|
|
2407
|
-
continue;
|
|
2408
|
-
}
|
|
2409
|
-
for (const fieldAuthorizationData of fieldAuthorizationDatas) {
|
|
2410
|
-
if (!(0, utils_3.mergeAuthorizationDataByAND)(authorizationData, fieldAuthorizationData)) {
|
|
2411
|
-
this.invalidOrScopesHostPaths.add(`${typeName}.${fieldAuthorizationData.fieldName}`);
|
|
2412
|
-
}
|
|
2413
|
-
}
|
|
2414
|
-
}
|
|
2415
|
-
if (this.invalidOrScopesHostPaths.size > 0) {
|
|
2416
|
-
this.errors.push((0, errors_1.orScopesLimitError)(utils_3.maxOrScopes, [...this.invalidOrScopesHostPaths]));
|
|
2313
|
+
if (this.invalidORScopesCoords.size > 0) {
|
|
2314
|
+
this.errors.push((0, errors_1.orScopesLimitError)(constants_1.MAX_OR_SCOPES, [...this.invalidORScopesCoords]));
|
|
2417
2315
|
}
|
|
2418
2316
|
const definitions = [];
|
|
2419
2317
|
for (const directiveDefinition of constants_1.BASE_DIRECTIVE_DEFINITIONS) {
|
|
@@ -2473,7 +2371,6 @@ class NormalizationFactory {
|
|
|
2473
2371
|
this.errors.push((0, errors_1.noDefinedEnumValuesError)(parentTypeName));
|
|
2474
2372
|
break;
|
|
2475
2373
|
}
|
|
2476
|
-
(0, utils_4.removeIgnoredDirectives)(parentDefinitionData);
|
|
2477
2374
|
definitions.push(this.getEnumNodeByData(parentDefinitionData));
|
|
2478
2375
|
break;
|
|
2479
2376
|
case graphql_1.Kind.INPUT_OBJECT_TYPE_DEFINITION:
|
|
@@ -2497,7 +2394,6 @@ class NormalizationFactory {
|
|
|
2497
2394
|
parentDefinitionData.fieldDataByFieldName.delete(string_constants_2.SERVICE_FIELD);
|
|
2498
2395
|
parentDefinitionData.fieldDataByFieldName.delete(string_constants_2.ENTITIES_FIELD);
|
|
2499
2396
|
}
|
|
2500
|
-
(0, utils_4.removeIgnoredDirectives)(parentDefinitionData);
|
|
2501
2397
|
(0, utils_4.removeInheritableDirectivesFromObjectParent)(parentDefinitionData);
|
|
2502
2398
|
if (this.parentsWithChildArguments.has(parentTypeName) || !isObject) {
|
|
2503
2399
|
const externalInterfaceFieldNames = [];
|
|
@@ -2544,7 +2440,6 @@ class NormalizationFactory {
|
|
|
2544
2440
|
this.errors.push((0, errors_1.noBaseScalarDefinitionError)(parentTypeName));
|
|
2545
2441
|
break;
|
|
2546
2442
|
}
|
|
2547
|
-
(0, utils_4.removeIgnoredDirectives)(parentDefinitionData);
|
|
2548
2443
|
definitions.push(this.getScalarNodeByData(parentDefinitionData));
|
|
2549
2444
|
break;
|
|
2550
2445
|
case graphql_1.Kind.UNION_TYPE_DEFINITION:
|
|
@@ -2651,6 +2546,7 @@ class NormalizationFactory {
|
|
|
2651
2546
|
configurationDataByTypeName: this.configurationDataByTypeName,
|
|
2652
2547
|
entityDataByTypeName: this.entityDataByTypeName,
|
|
2653
2548
|
entityInterfaces: this.entityInterfaceDataByTypeName,
|
|
2549
|
+
fieldCoordsByNamedTypeName: this.fieldCoordsByNamedTypeName,
|
|
2654
2550
|
isEventDrivenGraph: this.isSubgraphEventDrivenGraph,
|
|
2655
2551
|
isVersionTwo: this.isSubgraphVersionTwo,
|
|
2656
2552
|
keyFieldNamesByParentTypeName: this.keyFieldNamesByParentTypeName,
|
|
@@ -2681,7 +2577,8 @@ function batchNormalize(subgraphs) {
|
|
|
2681
2577
|
const subgraphNames = new Set();
|
|
2682
2578
|
const nonUniqueSubgraphNames = new Set();
|
|
2683
2579
|
const invalidNameErrorMessages = [];
|
|
2684
|
-
const
|
|
2580
|
+
const invalidORScopesCoords = new Set();
|
|
2581
|
+
const fieldCoordsByNamedTypeName = new Map();
|
|
2685
2582
|
const warnings = [];
|
|
2686
2583
|
const validationErrors = [];
|
|
2687
2584
|
// Record the subgraph names first, so that subgraph references can be validated
|
|
@@ -2711,7 +2608,10 @@ function batchNormalize(subgraphs) {
|
|
|
2711
2608
|
}
|
|
2712
2609
|
parentDefinitionDataMapsBySubgraphName.set(subgraphName, normalizationResult.parentDefinitionDataByTypeName);
|
|
2713
2610
|
for (const authorizationData of normalizationResult.authorizationDataByParentTypeName.values()) {
|
|
2714
|
-
(0, utils_3.upsertAuthorizationData)(authorizationDataByParentTypeName, authorizationData,
|
|
2611
|
+
(0, utils_3.upsertAuthorizationData)(authorizationDataByParentTypeName, authorizationData, invalidORScopesCoords);
|
|
2612
|
+
}
|
|
2613
|
+
for (const [namedTypeName, fieldCoords] of normalizationResult.fieldCoordsByNamedTypeName) {
|
|
2614
|
+
(0, utils_5.addIterableValuesToSet)(fieldCoords, (0, utils_5.getValueOrDefault)(fieldCoordsByNamedTypeName, namedTypeName, () => new Set()));
|
|
2715
2615
|
}
|
|
2716
2616
|
for (const [abstractTypeName, incomingConcreteTypeNames,] of normalizationResult.concreteTypeNamesByAbstractTypeName) {
|
|
2717
2617
|
const existingConcreteTypeNames = concreteTypeNamesByAbstractTypeName.get(abstractTypeName);
|
|
@@ -2781,8 +2681,8 @@ function batchNormalize(subgraphs) {
|
|
|
2781
2681
|
}
|
|
2782
2682
|
}
|
|
2783
2683
|
const allErrors = [];
|
|
2784
|
-
if (
|
|
2785
|
-
allErrors.push((0, errors_1.orScopesLimitError)(
|
|
2684
|
+
if (invalidORScopesCoords.size > 0) {
|
|
2685
|
+
allErrors.push((0, errors_1.orScopesLimitError)(constants_1.MAX_OR_SCOPES, [...invalidORScopesCoords]));
|
|
2786
2686
|
}
|
|
2787
2687
|
if (invalidNameErrorMessages.length > 0 || nonUniqueSubgraphNames.size > 0) {
|
|
2788
2688
|
allErrors.push((0, errors_1.invalidSubgraphNamesError)([...nonUniqueSubgraphNames], invalidNameErrorMessages));
|
|
@@ -2811,7 +2711,7 @@ function batchNormalize(subgraphs) {
|
|
|
2811
2711
|
if (!configurationData) {
|
|
2812
2712
|
continue;
|
|
2813
2713
|
}
|
|
2814
|
-
(0, utils_3.
|
|
2714
|
+
(0, utils_3.subtractSet)(fieldNames, configurationData.fieldNames);
|
|
2815
2715
|
if (configurationData.fieldNames.size < 1) {
|
|
2816
2716
|
internalSubgraph.configurationDataByTypeName.delete(parentTypeName);
|
|
2817
2717
|
}
|
|
@@ -2821,6 +2721,7 @@ function batchNormalize(subgraphs) {
|
|
|
2821
2721
|
authorizationDataByParentTypeName,
|
|
2822
2722
|
concreteTypeNamesByAbstractTypeName,
|
|
2823
2723
|
entityDataByTypeName,
|
|
2724
|
+
fieldCoordsByNamedTypeName,
|
|
2824
2725
|
internalSubgraphBySubgraphName: internalSubgraphBySubgraphName,
|
|
2825
2726
|
internalGraph,
|
|
2826
2727
|
success: true,
|