@wundergraph/composition 0.57.0 → 0.58.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{v1/normalization → directive-definition-data}/directive-definition-data.d.ts +2 -2
- package/dist/{v1/normalization → directive-definition-data}/directive-definition-data.js +308 -280
- package/dist/directive-definition-data/directive-definition-data.js.map +1 -0
- package/dist/directive-definition-data/types/params.d.ts +48 -0
- package/dist/directive-definition-data/types/params.js.map +1 -0
- package/dist/directive-definition-data/types/types.d.ts +39 -0
- package/dist/directive-definition-data/types/types.js.map +1 -0
- package/dist/directive-definition-data/utils.d.ts +5 -0
- package/dist/directive-definition-data/utils.js +75 -0
- package/dist/directive-definition-data/utils.js.map +1 -0
- package/dist/errors/errors.d.ts +35 -9
- package/dist/errors/errors.js +141 -21
- package/dist/errors/errors.js.map +1 -1
- package/dist/errors/{types.d.ts → types/params.d.ts} +34 -6
- package/dist/{federation → errors/types}/params.js.map +1 -1
- package/dist/errors/types/types.d.ts +5 -0
- package/dist/{federation → errors/types}/types.js.map +1 -1
- package/dist/federation/federation.d.ts +2 -2
- package/dist/federation/{params.d.ts → types/params.d.ts} +4 -4
- package/dist/{v1/federation → federation/types}/params.js.map +1 -1
- package/dist/federation/{types.d.ts → types/types.d.ts} +17 -20
- package/dist/{errors → federation/types}/types.js.map +1 -1
- package/dist/index.d.ts +16 -7
- package/dist/index.js +16 -7
- package/dist/index.js.map +1 -1
- package/dist/normalization/normalization.d.ts +2 -3
- package/dist/normalization/normalization.js +0 -8
- package/dist/normalization/normalization.js.map +1 -1
- package/dist/normalization/types.d.ts +21 -18
- package/dist/router-configuration/types.d.ts +1 -0
- package/dist/schema-building/ast.d.ts +2 -10
- package/dist/schema-building/ast.js +35 -32
- package/dist/schema-building/ast.js.map +1 -1
- package/dist/schema-building/types/params.d.ts +54 -0
- package/dist/schema-building/types/params.js.map +1 -0
- package/dist/schema-building/types/results.d.ts +39 -0
- package/dist/schema-building/types/results.js +3 -0
- package/dist/schema-building/types/results.js.map +1 -0
- package/dist/schema-building/{types.d.ts → types/types.d.ts} +21 -41
- package/dist/schema-building/types/types.js.map +1 -0
- package/dist/schema-building/utils.d.ts +21 -13
- package/dist/schema-building/utils.js +257 -82
- package/dist/schema-building/utils.js.map +1 -1
- package/dist/subgraph/types/params.d.ts +6 -0
- package/dist/subgraph/types/params.js +3 -0
- package/dist/{schema-building → subgraph/types}/params.js.map +1 -1
- package/dist/subgraph/types.d.ts +6 -6
- package/dist/subgraph/utils.d.ts +3 -0
- package/dist/subgraph/utils.js +23 -0
- package/dist/subgraph/utils.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/types/results.d.ts +14 -0
- package/dist/types/results.js +3 -0
- package/dist/types/results.js.map +1 -0
- package/dist/types/types.d.ts +2 -0
- package/dist/utils/composition-version.js +1 -1
- package/dist/utils/params.d.ts +4 -0
- package/dist/utils/string-constants.d.ts +2 -1
- package/dist/utils/string-constants.js +5 -4
- package/dist/utils/string-constants.js.map +1 -1
- package/dist/utils/utils.d.ts +2 -1
- package/dist/utils/utils.js +14 -0
- package/dist/utils/utils.js.map +1 -1
- package/dist/v1/constants/directive-definitions.js +3 -3
- package/dist/v1/constants/directive-definitions.js.map +1 -1
- package/dist/v1/constants/strings.d.ts +3 -1
- package/dist/v1/constants/strings.js +12 -2
- package/dist/v1/constants/strings.js.map +1 -1
- package/dist/v1/federation/federation-factory.d.ts +15 -16
- package/dist/v1/federation/federation-factory.js +344 -213
- package/dist/v1/federation/federation-factory.js.map +1 -1
- package/dist/v1/federation/{params.d.ts → types/params.d.ts} +16 -9
- package/dist/v1/federation/types/params.js +3 -0
- package/dist/v1/federation/types/params.js.map +1 -0
- package/dist/v1/federation/utils.d.ts +2 -2
- package/dist/v1/normalization/batch-normalization/batch-normalizer.d.ts +37 -0
- package/dist/v1/normalization/batch-normalization/batch-normalizer.js +245 -0
- package/dist/v1/normalization/batch-normalization/batch-normalizer.js.map +1 -0
- package/dist/v1/normalization/batch-normalization/types/params.d.ts +6 -0
- package/dist/v1/normalization/batch-normalization/types/params.js +3 -0
- package/dist/v1/normalization/batch-normalization/types/params.js.map +1 -0
- package/dist/v1/normalization/normalization-factory.d.ts +24 -19
- package/dist/v1/normalization/normalization-factory.js +263 -445
- package/dist/v1/normalization/normalization-factory.js.map +1 -1
- package/dist/v1/normalization/{params.d.ts → types/params.d.ts} +6 -12
- package/dist/v1/normalization/types/params.js +3 -0
- package/dist/v1/normalization/types/params.js.map +1 -0
- package/dist/v1/normalization/types/results.d.ts +26 -0
- package/dist/v1/normalization/types/results.js +3 -0
- package/dist/v1/normalization/types/results.js.map +1 -0
- package/dist/v1/normalization/types/types.d.ts +103 -0
- package/dist/v1/normalization/types/types.js +3 -0
- package/dist/v1/normalization/types/types.js.map +1 -0
- package/dist/v1/normalization/utils.d.ts +9 -2
- package/dist/v1/normalization/utils.js +308 -2
- package/dist/v1/normalization/utils.js.map +1 -1
- package/dist/v1/normalization/walkers.js +2 -1
- package/dist/v1/normalization/walkers.js.map +1 -1
- package/dist/v1/schema-building/type-merging.d.ts +1 -1
- package/dist/v1/utils/utils.d.ts +2 -3
- package/dist/v1/utils/utils.js +0 -17
- package/dist/v1/utils/utils.js.map +1 -1
- package/dist/v1/warnings/params.d.ts +6 -1
- package/dist/v1/warnings/warnings.d.ts +4 -1
- package/dist/v1/warnings/warnings.js +23 -0
- package/dist/v1/warnings/warnings.js.map +1 -1
- package/dist/validation/types/params.d.ts +22 -0
- package/dist/validation/types/params.js +3 -0
- package/dist/{v1/normalization → validation/types}/params.js.map +1 -1
- package/dist/validation/validation.d.ts +5 -0
- package/dist/validation/validation.js +213 -0
- package/dist/validation/validation.js.map +1 -0
- package/package.json +5 -4
- package/dist/schema-building/params.d.ts +0 -8
- package/dist/schema-building/types.js.map +0 -1
- package/dist/v1/normalization/directive-definition-data.js.map +0 -1
- package/dist/v1/normalization/types.d.ts +0 -79
- package/dist/v1/normalization/types.js.map +0 -1
- /package/dist/{federation → directive-definition-data/types}/params.js +0 -0
- /package/dist/{errors → directive-definition-data/types}/types.js +0 -0
- /package/dist/{schema-building → errors/types}/params.js +0 -0
- /package/dist/{federation → errors/types}/types.js +0 -0
- /package/dist/{v1/federation → federation/types}/params.js +0 -0
- /package/dist/{v1/normalization → federation/types}/types.js +0 -0
- /package/dist/{v1/normalization → schema-building/types}/params.js +0 -0
- /package/dist/schema-building/{types.js → types/types.js} +0 -0
|
@@ -13,9 +13,8 @@ const strings_1 = require("../constants/strings");
|
|
|
13
13
|
const utils_3 = require("../utils/utils");
|
|
14
14
|
const merge_1 = require("@graphql-tools/merge");
|
|
15
15
|
const constants_1 = require("../constants/constants");
|
|
16
|
-
const normalization_factory_1 = require("../normalization/normalization-factory");
|
|
17
16
|
const utils_4 = require("../normalization/utils");
|
|
18
|
-
const types_1 = require("../../schema-building/types");
|
|
17
|
+
const types_1 = require("../../schema-building/types/types");
|
|
19
18
|
const utils_5 = require("../../schema-building/utils");
|
|
20
19
|
const walkers_1 = require("./walkers");
|
|
21
20
|
const lodash_1 = require("lodash");
|
|
@@ -25,6 +24,7 @@ const integer_constants_1 = require("../../utils/integer-constants");
|
|
|
25
24
|
const utils_6 = require("../../utils/utils");
|
|
26
25
|
const warnings_1 = require("../warnings/warnings");
|
|
27
26
|
const directive_definitions_1 = require("../constants/directive-definitions");
|
|
27
|
+
const batch_normalizer_1 = require("../normalization/batch-normalization/batch-normalizer");
|
|
28
28
|
class FederationFactory {
|
|
29
29
|
authorizationDataByParentTypeName;
|
|
30
30
|
coordsByNamedTypeName = new Map();
|
|
@@ -35,7 +35,9 @@ class FederationFactory {
|
|
|
35
35
|
subgraphNamesByNamedTypeNameByFieldCoords = new Map();
|
|
36
36
|
entityDataByTypeName;
|
|
37
37
|
entityInterfaceFederationDataByTypeName;
|
|
38
|
+
executableDirectiveDatasByName;
|
|
38
39
|
errors = [];
|
|
40
|
+
federatedDirectiveDataByName;
|
|
39
41
|
fieldConfigurationByFieldCoords = new Map();
|
|
40
42
|
fieldCoordsByNamedTypeName;
|
|
41
43
|
inaccessibleCoords = new Set();
|
|
@@ -51,41 +53,36 @@ class FederationFactory {
|
|
|
51
53
|
options;
|
|
52
54
|
parentDefinitionDataByTypeName = new Map();
|
|
53
55
|
parentTagDataByTypeName = new Map();
|
|
54
|
-
|
|
55
|
-
[string_constants_1.AUTHENTICATED, directive_definitions_1.AUTHENTICATED_DEFINITION],
|
|
56
|
-
[string_constants_1.DEPRECATED, directive_definitions_1.DEPRECATED_DEFINITION],
|
|
57
|
-
[string_constants_1.INACCESSIBLE, directive_definitions_1.INACCESSIBLE_DEFINITION],
|
|
58
|
-
[string_constants_1.ONE_OF, directive_definitions_1.ONE_OF_DEFINITION],
|
|
59
|
-
[string_constants_1.REQUIRES_SCOPES, directive_definitions_1.REQUIRES_SCOPES_DEFINITION],
|
|
60
|
-
[string_constants_1.SEMANTIC_NON_NULL, directive_definitions_1.SEMANTIC_NON_NULL_DEFINITION],
|
|
61
|
-
[string_constants_1.TAG, directive_definitions_1.TAG_DEFINITION],
|
|
62
|
-
]);
|
|
63
|
-
potentialPersistedDirectiveDefinitionDataByDirectiveName = new Map();
|
|
64
|
-
referencedPersistedDirectiveNames = new Set();
|
|
56
|
+
referencedFederatedDirectiveNames = new Set();
|
|
65
57
|
routerDefinitions = [];
|
|
66
58
|
subscriptionFilterDataByFieldPath = new Map();
|
|
67
59
|
tagNamesByCoords = new Map();
|
|
68
60
|
warnings;
|
|
69
|
-
constructor({ authorizationDataByParentTypeName, concreteTypeNamesByAbstractTypeName, entityDataByTypeName, entityInterfaceFederationDataByTypeName, fieldCoordsByNamedTypeName, interfaceImplementationTypeNamesByInterfaceTypeName, internalGraph, internalSubgraphBySubgraphName, options, warnings, }) {
|
|
61
|
+
constructor({ authorizationDataByParentTypeName, concreteTypeNamesByAbstractTypeName, entityDataByTypeName, entityInterfaceFederationDataByTypeName, executableDirectiveDatasByName, federatedDirectiveDataByName, fieldCoordsByNamedTypeName, interfaceImplementationTypeNamesByInterfaceTypeName, internalGraph, internalSubgraphBySubgraphName, options, warnings, }) {
|
|
70
62
|
this.authorizationDataByParentTypeName = authorizationDataByParentTypeName;
|
|
71
63
|
this.options = options ?? {};
|
|
72
64
|
this.concreteTypeNamesByAbstractTypeName = concreteTypeNamesByAbstractTypeName;
|
|
65
|
+
this.executableDirectiveDatasByName = executableDirectiveDatasByName;
|
|
73
66
|
this.entityDataByTypeName = entityDataByTypeName;
|
|
74
67
|
this.entityInterfaceFederationDataByTypeName = entityInterfaceFederationDataByTypeName;
|
|
68
|
+
this.federatedDirectiveDataByName = federatedDirectiveDataByName;
|
|
69
|
+
for (const data of utils_4.FEDERATED_DIRECTIVE_DATAS) {
|
|
70
|
+
this.federatedDirectiveDataByName.set(data.name, data);
|
|
71
|
+
}
|
|
75
72
|
this.fieldCoordsByNamedTypeName = fieldCoordsByNamedTypeName;
|
|
76
73
|
this.interfaceImplementationTypeNamesByInterfaceTypeName = interfaceImplementationTypeNamesByInterfaceTypeName;
|
|
77
74
|
this.internalGraph = internalGraph;
|
|
78
75
|
this.internalSubgraphBySubgraphName = internalSubgraphBySubgraphName;
|
|
79
76
|
this.warnings = warnings;
|
|
80
77
|
}
|
|
81
|
-
|
|
78
|
+
extractFederatedDirectives({ data, directivesByName }) {
|
|
82
79
|
for (const [directiveName, directiveNodes] of directivesByName) {
|
|
83
|
-
const
|
|
84
|
-
|
|
85
|
-
if (!definition) {
|
|
80
|
+
const federatedData = this.federatedDirectiveDataByName.get(directiveName);
|
|
81
|
+
if (!federatedData) {
|
|
86
82
|
continue;
|
|
87
83
|
}
|
|
88
|
-
this.
|
|
84
|
+
this.referencedFederatedDirectiveNames.add(directiveName);
|
|
85
|
+
// @authenticated and @requiresScopes are handled differently
|
|
89
86
|
if (string_constants_1.AUTHORIZATION_DIRECTIVES.has(directiveName) || directiveNodes.length < 1) {
|
|
90
87
|
continue;
|
|
91
88
|
}
|
|
@@ -106,7 +103,7 @@ class FederationFactory {
|
|
|
106
103
|
break;
|
|
107
104
|
}
|
|
108
105
|
// Only add one instance of certain directives.
|
|
109
|
-
if (string_constants_1.
|
|
106
|
+
if (string_constants_1.NON_REPEATABLE_FEDERATED_DIRECTIVES.has(directiveName)) {
|
|
110
107
|
break;
|
|
111
108
|
}
|
|
112
109
|
existingDirectives.push(...directiveNodes);
|
|
@@ -236,7 +233,7 @@ class FederationFactory {
|
|
|
236
233
|
const graphNode = this.internalGraph.nodeByNodeName.get(`${this.currentSubgraphName}.${entityData.typeName}`);
|
|
237
234
|
// Any errors in the field sets would be caught when evaluating the explicit entities, so they are ignored here
|
|
238
235
|
(0, utils_2.validateImplicitFieldSets)({
|
|
239
|
-
conditionalFieldDataByCoords: internalSubgraph.
|
|
236
|
+
conditionalFieldDataByCoords: internalSubgraph.conditionalFieldDataByCoords,
|
|
240
237
|
currentSubgraphName: this.currentSubgraphName,
|
|
241
238
|
entityData,
|
|
242
239
|
implicitKeys,
|
|
@@ -253,7 +250,7 @@ class FederationFactory {
|
|
|
253
250
|
continue;
|
|
254
251
|
}
|
|
255
252
|
(0, utils_2.validateImplicitFieldSets)({
|
|
256
|
-
conditionalFieldDataByCoords: internalSubgraph.
|
|
253
|
+
conditionalFieldDataByCoords: internalSubgraph.conditionalFieldDataByCoords,
|
|
257
254
|
currentSubgraphName: this.currentSubgraphName,
|
|
258
255
|
entityData: interfaceObjectEntityData,
|
|
259
256
|
implicitKeys,
|
|
@@ -289,7 +286,7 @@ class FederationFactory {
|
|
|
289
286
|
const implicitKeys = [];
|
|
290
287
|
// Any errors in the field sets would be caught when evaluating the explicit entities, so they are ignored here
|
|
291
288
|
(0, utils_2.validateImplicitFieldSets)({
|
|
292
|
-
conditionalFieldDataByCoords: internalSubgraph.
|
|
289
|
+
conditionalFieldDataByCoords: internalSubgraph.conditionalFieldDataByCoords,
|
|
293
290
|
currentSubgraphName: internalSubgraph.name,
|
|
294
291
|
entityData,
|
|
295
292
|
implicitKeys,
|
|
@@ -360,8 +357,8 @@ class FederationFactory {
|
|
|
360
357
|
upsertEnumValueData(enumValueDataByName, incomingData, isParentInaccessible) {
|
|
361
358
|
const existingData = enumValueDataByName.get(incomingData.name);
|
|
362
359
|
const targetData = existingData || this.copyEnumValueData(incomingData);
|
|
363
|
-
this.
|
|
364
|
-
data: targetData.
|
|
360
|
+
this.extractFederatedDirectives({
|
|
361
|
+
data: targetData.federatedDirectivesData,
|
|
365
362
|
directivesByName: incomingData.directivesByName,
|
|
366
363
|
});
|
|
367
364
|
const isValueInaccessible = (0, utils_5.isNodeDataInaccessible)(incomingData);
|
|
@@ -381,18 +378,61 @@ class FederationFactory {
|
|
|
381
378
|
target: targetData.subgraphNames,
|
|
382
379
|
});
|
|
383
380
|
}
|
|
381
|
+
upsertDirectiveArgumentData({ argumentDataByName, incomingData }) {
|
|
382
|
+
const existingData = argumentDataByName.get(incomingData.name);
|
|
383
|
+
const targetData = existingData || this.copyDirectiveArgumentData(incomingData);
|
|
384
|
+
this.extractFederatedDirectives({
|
|
385
|
+
data: targetData.federatedDirectivesData,
|
|
386
|
+
directivesByName: incomingData.directivesByName,
|
|
387
|
+
});
|
|
388
|
+
if (!existingData) {
|
|
389
|
+
this.namedInputValueTypeNames.add(targetData.namedTypeName);
|
|
390
|
+
argumentDataByName.set(targetData.name, targetData);
|
|
391
|
+
return;
|
|
392
|
+
}
|
|
393
|
+
if (!incomingData.defaultValue) {
|
|
394
|
+
existingData.includeDefaultValue = false;
|
|
395
|
+
}
|
|
396
|
+
(0, utils_6.addNewObjectValueMapEntries)(incomingData.configureDescriptionDataBySubgraphName, targetData.configureDescriptionDataBySubgraphName);
|
|
397
|
+
(0, utils_5.setLongestDescription)(targetData, incomingData);
|
|
398
|
+
(0, utils_6.addIterableToSet)({
|
|
399
|
+
source: incomingData.subgraphNames,
|
|
400
|
+
target: targetData.subgraphNames,
|
|
401
|
+
});
|
|
402
|
+
(0, utils_6.addIterableToSet)({
|
|
403
|
+
source: incomingData.requiredSubgraphNames,
|
|
404
|
+
target: targetData.requiredSubgraphNames,
|
|
405
|
+
});
|
|
406
|
+
// TODO refactor type merging
|
|
407
|
+
const mergeResult = (0, type_merging_1.getMostRestrictiveMergedTypeNode)(targetData.type, incomingData.type, incomingData.federatedCoords, this.errors);
|
|
408
|
+
if (mergeResult.success) {
|
|
409
|
+
targetData.type = mergeResult.typeNode;
|
|
410
|
+
}
|
|
411
|
+
else {
|
|
412
|
+
this.errors.push((0, errors_1.incompatibleMergedTypesError)({
|
|
413
|
+
actualType: mergeResult.actualType,
|
|
414
|
+
isArgument: true,
|
|
415
|
+
coords: incomingData.federatedCoords,
|
|
416
|
+
expectedType: mergeResult.expectedType,
|
|
417
|
+
}));
|
|
418
|
+
}
|
|
419
|
+
const validationResult = (0, utils_5.compareAndValidateInputDefaultValues)({ existingData, incomingData });
|
|
420
|
+
if (!validationResult.success) {
|
|
421
|
+
this.errors.push(validationResult.error);
|
|
422
|
+
}
|
|
423
|
+
}
|
|
384
424
|
// To facilitate the splitting of tag paths, field arguments do not use the renamedPath property for tagNamesByPath
|
|
385
425
|
upsertInputValueData(inputValueDataByValueName, incomingData, parentCoords, isParentInaccessible) {
|
|
386
426
|
const existingData = inputValueDataByValueName.get(incomingData.name);
|
|
387
427
|
const targetData = existingData || this.copyInputValueData(incomingData);
|
|
388
|
-
this.
|
|
389
|
-
data: targetData.
|
|
428
|
+
this.extractFederatedDirectives({
|
|
429
|
+
data: targetData.federatedDirectivesData,
|
|
390
430
|
directivesByName: incomingData.directivesByName,
|
|
391
431
|
});
|
|
392
432
|
this.recordTagNamesByCoords(targetData, `${parentCoords}.${targetData.name}`);
|
|
393
|
-
this.namedInputValueTypeNames.add(targetData.namedTypeName);
|
|
394
433
|
(0, utils_6.getValueOrDefault)(this.coordsByNamedTypeName, targetData.namedTypeName, () => new Set()).add(targetData.federatedCoords);
|
|
395
434
|
if (!existingData) {
|
|
435
|
+
this.namedInputValueTypeNames.add(targetData.namedTypeName);
|
|
396
436
|
inputValueDataByValueName.set(targetData.name, targetData);
|
|
397
437
|
return;
|
|
398
438
|
}
|
|
@@ -420,7 +460,10 @@ class FederationFactory {
|
|
|
420
460
|
expectedType: mergeResult.expectedType,
|
|
421
461
|
}));
|
|
422
462
|
}
|
|
423
|
-
(0, utils_5.
|
|
463
|
+
const validationResult = (0, utils_5.compareAndValidateInputDefaultValues)({ existingData, incomingData });
|
|
464
|
+
if (!validationResult.success) {
|
|
465
|
+
this.errors.push(validationResult.error);
|
|
466
|
+
}
|
|
424
467
|
}
|
|
425
468
|
handleInputValueInaccessibility(isParentInaccessible, inputValueData, parentCoords) {
|
|
426
469
|
/* If an ancestor (Input Object for field; Composite type or field for argument) of the input value is
|
|
@@ -545,8 +588,8 @@ class FederationFactory {
|
|
|
545
588
|
(0, utils_6.getValueOrDefault)(this.coordsByNamedTypeName, incomingData.namedTypeName, () => new Set()).add(targetData.federatedCoords);
|
|
546
589
|
this.namedOutputTypeNames.add(incomingData.namedTypeName);
|
|
547
590
|
this.handleSubscriptionFilterDirective(incomingData, targetData);
|
|
548
|
-
this.
|
|
549
|
-
data: targetData.
|
|
591
|
+
this.extractFederatedDirectives({
|
|
592
|
+
data: targetData.federatedDirectivesData,
|
|
550
593
|
directivesByName: incomingData.directivesByName,
|
|
551
594
|
});
|
|
552
595
|
const isFieldInaccessible = isParentInaccessible || (0, utils_5.isNodeDataInaccessible)(targetData);
|
|
@@ -623,11 +666,11 @@ class FederationFactory {
|
|
|
623
666
|
}
|
|
624
667
|
recordTagNamesByCoords(data, coords) {
|
|
625
668
|
const path = coords || data.name;
|
|
626
|
-
if (data.
|
|
669
|
+
if (data.federatedDirectivesData.tagDirectiveByName.size < 1) {
|
|
627
670
|
return;
|
|
628
671
|
}
|
|
629
672
|
const tagNames = (0, utils_6.getValueOrDefault)(this.tagNamesByCoords, path, () => new Set());
|
|
630
|
-
for (const tagName of data.
|
|
673
|
+
for (const tagName of data.federatedDirectivesData.tagDirectiveByName.keys()) {
|
|
631
674
|
tagNames.add(tagName);
|
|
632
675
|
}
|
|
633
676
|
}
|
|
@@ -637,13 +680,41 @@ class FederationFactory {
|
|
|
637
680
|
directivesByName: (0, utils_6.copyArrayValueMap)(sourceData.directivesByName),
|
|
638
681
|
extensionType: sourceData.extensionType,
|
|
639
682
|
name: sourceData.name,
|
|
640
|
-
|
|
641
|
-
data: (0, utils_5.
|
|
683
|
+
federatedDirectivesData: this.extractFederatedDirectives({
|
|
684
|
+
data: (0, utils_5.newFederatedDirectivesData)(),
|
|
642
685
|
directivesByName: sourceData.directivesByName,
|
|
643
686
|
}),
|
|
644
687
|
description: (0, utils_5.getInitialFederatedDescription)(sourceData),
|
|
645
688
|
};
|
|
646
689
|
}
|
|
690
|
+
copyDirectiveArgumentData(sourceData) {
|
|
691
|
+
return {
|
|
692
|
+
configureDescriptionDataBySubgraphName: (0, utils_6.copyObjectValueMap)(sourceData.configureDescriptionDataBySubgraphName),
|
|
693
|
+
directivesByName: (0, utils_6.copyArrayValueMap)(sourceData.directivesByName),
|
|
694
|
+
defaultValue: sourceData.defaultValue,
|
|
695
|
+
description: (0, utils_5.getInitialFederatedDescription)(sourceData),
|
|
696
|
+
federatedCoords: sourceData.federatedCoords,
|
|
697
|
+
federatedDirectivesData: this.extractFederatedDirectives({
|
|
698
|
+
data: (0, utils_5.newFederatedDirectivesData)(),
|
|
699
|
+
directivesByName: sourceData.directivesByName,
|
|
700
|
+
}),
|
|
701
|
+
includeDefaultValue: sourceData.includeDefaultValue,
|
|
702
|
+
kind: sourceData.kind,
|
|
703
|
+
name: sourceData.name,
|
|
704
|
+
namedTypeKind: sourceData.namedTypeKind,
|
|
705
|
+
namedTypeName: sourceData.namedTypeName,
|
|
706
|
+
node: {
|
|
707
|
+
directives: [],
|
|
708
|
+
kind: graphql_1.Kind.INPUT_VALUE_DEFINITION,
|
|
709
|
+
name: (0, utils_1.stringToNameNode)(sourceData.name),
|
|
710
|
+
type: sourceData.type,
|
|
711
|
+
},
|
|
712
|
+
originalCoords: sourceData.originalCoords,
|
|
713
|
+
requiredSubgraphNames: new Set(sourceData.requiredSubgraphNames),
|
|
714
|
+
subgraphNames: new Set(sourceData.subgraphNames),
|
|
715
|
+
type: sourceData.type,
|
|
716
|
+
};
|
|
717
|
+
}
|
|
647
718
|
copyEnumValueData(sourceData) {
|
|
648
719
|
return {
|
|
649
720
|
appearances: sourceData.appearances,
|
|
@@ -658,8 +729,8 @@ class FederationFactory {
|
|
|
658
729
|
name: (0, utils_1.stringToNameNode)(sourceData.name),
|
|
659
730
|
},
|
|
660
731
|
parentTypeName: sourceData.parentTypeName,
|
|
661
|
-
|
|
662
|
-
data: (0, utils_5.
|
|
732
|
+
federatedDirectivesData: this.extractFederatedDirectives({
|
|
733
|
+
data: (0, utils_5.newFederatedDirectivesData)(),
|
|
663
734
|
directivesByName: sourceData.directivesByName,
|
|
664
735
|
}),
|
|
665
736
|
subgraphNames: new Set(sourceData.subgraphNames),
|
|
@@ -686,8 +757,8 @@ class FederationFactory {
|
|
|
686
757
|
},
|
|
687
758
|
originalCoords: sourceData.originalCoords,
|
|
688
759
|
originalParentTypeName: sourceData.originalParentTypeName,
|
|
689
|
-
|
|
690
|
-
data: (0, utils_5.
|
|
760
|
+
federatedDirectivesData: this.extractFederatedDirectives({
|
|
761
|
+
data: (0, utils_5.newFederatedDirectivesData)(),
|
|
691
762
|
directivesByName: sourceData.directivesByName,
|
|
692
763
|
}),
|
|
693
764
|
renamedParentTypeName: sourceData.renamedParentTypeName,
|
|
@@ -734,8 +805,8 @@ class FederationFactory {
|
|
|
734
805
|
},
|
|
735
806
|
nullLevelsBySubgraphName: sourceData.nullLevelsBySubgraphName,
|
|
736
807
|
originalParentTypeName: sourceData.originalParentTypeName,
|
|
737
|
-
|
|
738
|
-
data: (0, utils_5.
|
|
808
|
+
federatedDirectivesData: this.extractFederatedDirectives({
|
|
809
|
+
data: (0, utils_5.newFederatedDirectivesData)(),
|
|
739
810
|
directivesByName: sourceData.directivesByName,
|
|
740
811
|
}),
|
|
741
812
|
renamedParentTypeName: sourceData.renamedParentTypeName,
|
|
@@ -871,8 +942,8 @@ class FederationFactory {
|
|
|
871
942
|
}
|
|
872
943
|
return targetData;
|
|
873
944
|
}
|
|
874
|
-
this.
|
|
875
|
-
data: existingData.
|
|
945
|
+
this.extractFederatedDirectives({
|
|
946
|
+
data: existingData.federatedDirectivesData,
|
|
876
947
|
directivesByName: incomingData.directivesByName,
|
|
877
948
|
});
|
|
878
949
|
return existingData;
|
|
@@ -1009,51 +1080,6 @@ class FederationFactory {
|
|
|
1009
1080
|
}
|
|
1010
1081
|
}
|
|
1011
1082
|
}
|
|
1012
|
-
upsertPersistedDirectiveDefinitionData(incomingData, subgraphNumber) {
|
|
1013
|
-
const name = incomingData.name;
|
|
1014
|
-
const existingData = this.potentialPersistedDirectiveDefinitionDataByDirectiveName.get(name);
|
|
1015
|
-
if (!existingData) {
|
|
1016
|
-
// The executable directive must be defined in all subgraphs to be persisted.
|
|
1017
|
-
if (subgraphNumber > 1) {
|
|
1018
|
-
return;
|
|
1019
|
-
}
|
|
1020
|
-
const argumentDataByArgumentName = new Map();
|
|
1021
|
-
for (const inputValueData of incomingData.argumentDataByName.values()) {
|
|
1022
|
-
this.namedInputValueTypeNames.add(inputValueData.namedTypeName);
|
|
1023
|
-
this.upsertInputValueData(argumentDataByArgumentName, inputValueData, `@${incomingData.name}`, false);
|
|
1024
|
-
}
|
|
1025
|
-
this.potentialPersistedDirectiveDefinitionDataByDirectiveName.set(name, {
|
|
1026
|
-
argumentDataByName: argumentDataByArgumentName,
|
|
1027
|
-
executableLocations: new Set(incomingData.executableLocations),
|
|
1028
|
-
name,
|
|
1029
|
-
repeatable: incomingData.repeatable,
|
|
1030
|
-
subgraphNames: new Set(incomingData.subgraphNames),
|
|
1031
|
-
description: incomingData.description,
|
|
1032
|
-
});
|
|
1033
|
-
return;
|
|
1034
|
-
}
|
|
1035
|
-
// If the executable directive has not been defined in at least one graph, the definition should not be persisted
|
|
1036
|
-
if (existingData.subgraphNames.size + 1 !== subgraphNumber) {
|
|
1037
|
-
this.potentialPersistedDirectiveDefinitionDataByDirectiveName.delete(name);
|
|
1038
|
-
return;
|
|
1039
|
-
}
|
|
1040
|
-
(0, utils_5.setMutualExecutableLocations)(existingData, incomingData.executableLocations);
|
|
1041
|
-
// If there are no mutually defined executable locations, the definition should not be persisted
|
|
1042
|
-
if (existingData.executableLocations.size < 1) {
|
|
1043
|
-
this.potentialPersistedDirectiveDefinitionDataByDirectiveName.delete(name);
|
|
1044
|
-
return;
|
|
1045
|
-
}
|
|
1046
|
-
for (const inputValueData of incomingData.argumentDataByName.values()) {
|
|
1047
|
-
this.namedInputValueTypeNames.add((0, ast_1.getTypeNodeNamedTypeName)(inputValueData.type));
|
|
1048
|
-
this.upsertInputValueData(existingData.argumentDataByName, inputValueData, `@${existingData.name}`, false);
|
|
1049
|
-
}
|
|
1050
|
-
(0, utils_5.setLongestDescription)(existingData, incomingData);
|
|
1051
|
-
existingData.repeatable &&= incomingData.repeatable;
|
|
1052
|
-
(0, utils_6.addIterableToSet)({
|
|
1053
|
-
source: incomingData.subgraphNames,
|
|
1054
|
-
target: existingData.subgraphNames,
|
|
1055
|
-
});
|
|
1056
|
-
}
|
|
1057
1083
|
shouldUpdateFederatedFieldAbstractNamedType(abstractTypeName, objectTypeNames) {
|
|
1058
1084
|
if (!abstractTypeName) {
|
|
1059
1085
|
return false;
|
|
@@ -1194,38 +1220,72 @@ class FederationFactory {
|
|
|
1194
1220
|
this.updateTypeNodeNamedType(fieldData.type, abstractTypeName);
|
|
1195
1221
|
}
|
|
1196
1222
|
}
|
|
1223
|
+
upsertExecutableDirectiveDatas() {
|
|
1224
|
+
for (const [directiveName, definitionDatas] of this.executableDirectiveDatasByName) {
|
|
1225
|
+
for (const data of definitionDatas) {
|
|
1226
|
+
const existingData = this.federatedDirectiveDataByName.get(directiveName);
|
|
1227
|
+
if (!existingData) {
|
|
1228
|
+
const argumentDataByName = new Map();
|
|
1229
|
+
for (const argumentData of data.argumentDataByName.values()) {
|
|
1230
|
+
this.upsertDirectiveArgumentData({
|
|
1231
|
+
argumentDataByName,
|
|
1232
|
+
incomingData: argumentData,
|
|
1233
|
+
});
|
|
1234
|
+
}
|
|
1235
|
+
// Shared set between locations and executable locations because type-system locations are removed.
|
|
1236
|
+
const locations = new Set(data.executableLocations);
|
|
1237
|
+
this.federatedDirectiveDataByName.set(directiveName, {
|
|
1238
|
+
argumentDataByName,
|
|
1239
|
+
isComposed: false,
|
|
1240
|
+
isRepeatable: data.isRepeatable,
|
|
1241
|
+
isReferenced: data.isReferenced,
|
|
1242
|
+
executableLocations: locations,
|
|
1243
|
+
locations,
|
|
1244
|
+
majorVersion: -1,
|
|
1245
|
+
minorVersion: -1,
|
|
1246
|
+
name: directiveName,
|
|
1247
|
+
description: data.description,
|
|
1248
|
+
node: data.node,
|
|
1249
|
+
optionalArgumentNames: new Set(data.optionalArgumentNames),
|
|
1250
|
+
requiredArgumentNames: new Set(data.requiredArgumentNames),
|
|
1251
|
+
subgraphNames: new Set(data.subgraphNames),
|
|
1252
|
+
});
|
|
1253
|
+
continue;
|
|
1254
|
+
}
|
|
1255
|
+
for (const argumentData of data.argumentDataByName.values()) {
|
|
1256
|
+
this.upsertDirectiveArgumentData({
|
|
1257
|
+
argumentDataByName: existingData.argumentDataByName,
|
|
1258
|
+
incomingData: argumentData,
|
|
1259
|
+
});
|
|
1260
|
+
}
|
|
1261
|
+
for (const executableLocation of existingData.executableLocations) {
|
|
1262
|
+
if (!data.executableLocations.has(executableLocation)) {
|
|
1263
|
+
existingData.executableLocations.delete(executableLocation);
|
|
1264
|
+
}
|
|
1265
|
+
}
|
|
1266
|
+
if (existingData.executableLocations.size < 1) {
|
|
1267
|
+
this.federatedDirectiveDataByName.delete(directiveName);
|
|
1268
|
+
break;
|
|
1269
|
+
}
|
|
1270
|
+
(0, utils_5.setLongestDescription)(existingData, data);
|
|
1271
|
+
(0, utils_6.addIterableToSet)({ source: data.subgraphNames, target: existingData.subgraphNames });
|
|
1272
|
+
existingData.isRepeatable &&= data.isRepeatable;
|
|
1273
|
+
}
|
|
1274
|
+
}
|
|
1275
|
+
}
|
|
1197
1276
|
/* federateInternalSubgraphData is responsible for merging each subgraph TypeScript representation of a GraphQL type
|
|
1198
1277
|
* into a single representation.
|
|
1199
1278
|
* This method is always necessary, regardless of whether federating a source graph or contract graph.
|
|
1200
1279
|
* */
|
|
1201
1280
|
federateInternalSubgraphData() {
|
|
1202
|
-
|
|
1203
|
-
let shouldSkipPersistedExecutableDirectives = false;
|
|
1281
|
+
this.upsertExecutableDirectiveDatas();
|
|
1204
1282
|
for (const internalSubgraph of this.internalSubgraphBySubgraphName.values()) {
|
|
1205
|
-
subgraphNumber += 1;
|
|
1206
1283
|
this.currentSubgraphName = internalSubgraph.name;
|
|
1207
1284
|
this.isVersionTwo ||= internalSubgraph.isVersionTwo;
|
|
1208
1285
|
(0, walkers_1.renameRootTypes)(this, internalSubgraph);
|
|
1209
1286
|
for (const parentDefinitionData of internalSubgraph.parentDefinitionDataByTypeName.values()) {
|
|
1210
1287
|
this.upsertParentDefinitionData(parentDefinitionData, internalSubgraph.name);
|
|
1211
1288
|
}
|
|
1212
|
-
if (shouldSkipPersistedExecutableDirectives) {
|
|
1213
|
-
continue;
|
|
1214
|
-
}
|
|
1215
|
-
/* If a subgraph defines no executable directives, it is not possible for any definition to be in all subgraphs.
|
|
1216
|
-
Consequently, it is no longer necessary to check for any persisted executable directives. */
|
|
1217
|
-
if (!internalSubgraph.persistedDirectiveDefinitionDataByDirectiveName.size) {
|
|
1218
|
-
shouldSkipPersistedExecutableDirectives = true;
|
|
1219
|
-
continue;
|
|
1220
|
-
}
|
|
1221
|
-
for (const persistedDirectiveDefinitionData of internalSubgraph.persistedDirectiveDefinitionDataByDirectiveName.values()) {
|
|
1222
|
-
this.upsertPersistedDirectiveDefinitionData(persistedDirectiveDefinitionData, subgraphNumber);
|
|
1223
|
-
}
|
|
1224
|
-
/* Invalid directive keys are deleted; if there are no entries left, it is no longer necessary to evaluate more
|
|
1225
|
-
executable directives. */
|
|
1226
|
-
if (this.potentialPersistedDirectiveDefinitionDataByDirectiveName.size < 1) {
|
|
1227
|
-
shouldSkipPersistedExecutableDirectives = true;
|
|
1228
|
-
}
|
|
1229
1289
|
}
|
|
1230
1290
|
this.handleDisparateFieldNamedTypes();
|
|
1231
1291
|
}
|
|
@@ -1362,38 +1422,6 @@ class FederationFactory {
|
|
|
1362
1422
|
subgraphNames: fieldData.subgraphNames,
|
|
1363
1423
|
};
|
|
1364
1424
|
}
|
|
1365
|
-
getValidFlattenedPersistedDirectiveNodeArray(data) {
|
|
1366
|
-
const coords = (0, utils_3.getNodeCoords)(data);
|
|
1367
|
-
const persistedDirectiveNodes = [];
|
|
1368
|
-
for (const [directiveName, directiveNodes] of data.persistedDirectivesData.directivesByName) {
|
|
1369
|
-
if (directiveName === string_constants_1.SEMANTIC_NON_NULL && (0, utils_5.isFieldData)(data)) {
|
|
1370
|
-
persistedDirectiveNodes.push((0, utils_6.generateSemanticNonNullDirective)((0, utils_6.getFirstEntry)(data.nullLevelsBySubgraphName) ?? new Set([0])));
|
|
1371
|
-
continue;
|
|
1372
|
-
}
|
|
1373
|
-
const persistedDirectiveDefinition = this.persistedDirectiveDefinitionByDirectiveName.get(directiveName);
|
|
1374
|
-
if (!persistedDirectiveDefinition) {
|
|
1375
|
-
continue;
|
|
1376
|
-
}
|
|
1377
|
-
if (directiveNodes.length < 2) {
|
|
1378
|
-
persistedDirectiveNodes.push(...directiveNodes);
|
|
1379
|
-
continue;
|
|
1380
|
-
}
|
|
1381
|
-
if (!persistedDirectiveDefinition.repeatable) {
|
|
1382
|
-
this.errors.push((0, errors_1.invalidRepeatedFederatedDirectiveErrorMessage)(directiveName, coords));
|
|
1383
|
-
continue;
|
|
1384
|
-
}
|
|
1385
|
-
persistedDirectiveNodes.push(...directiveNodes);
|
|
1386
|
-
}
|
|
1387
|
-
return persistedDirectiveNodes;
|
|
1388
|
-
}
|
|
1389
|
-
getRouterPersistedDirectiveNodes(nodeData) {
|
|
1390
|
-
const persistedDirectiveNodes = [...nodeData.persistedDirectivesData.tagDirectiveByName.values()];
|
|
1391
|
-
if (nodeData.persistedDirectivesData.isDeprecated) {
|
|
1392
|
-
persistedDirectiveNodes.push((0, utils_5.generateDeprecatedDirective)(nodeData.persistedDirectivesData.deprecatedReason));
|
|
1393
|
-
}
|
|
1394
|
-
persistedDirectiveNodes.push(...this.getValidFlattenedPersistedDirectiveNodeArray(nodeData));
|
|
1395
|
-
return persistedDirectiveNodes;
|
|
1396
|
-
}
|
|
1397
1425
|
getFederatedGraphNodeDescription(data) {
|
|
1398
1426
|
if (data.configureDescriptionDataBySubgraphName.size < 1) {
|
|
1399
1427
|
return data.description;
|
|
@@ -1416,31 +1444,27 @@ class FederationFactory {
|
|
|
1416
1444
|
}
|
|
1417
1445
|
this.errors.push((0, errors_1.configureDescriptionPropagationError)((0, utils_5.getDefinitionDataCoords)(data, true), subgraphNames));
|
|
1418
1446
|
}
|
|
1419
|
-
getNodeForRouterSchemaByData(data) {
|
|
1420
|
-
data.node.name = (0, utils_1.stringToNameNode)(data.name);
|
|
1421
|
-
data.node.description = this.getFederatedGraphNodeDescription(data);
|
|
1422
|
-
data.node.directives = this.getRouterPersistedDirectiveNodes(data);
|
|
1423
|
-
return data.node;
|
|
1424
|
-
}
|
|
1425
|
-
getNodeWithPersistedDirectivesByInputValueData(inputValueData) {
|
|
1426
|
-
inputValueData.node.name = (0, utils_1.stringToNameNode)(inputValueData.name);
|
|
1427
|
-
inputValueData.node.type = inputValueData.type;
|
|
1428
|
-
inputValueData.node.description = this.getFederatedGraphNodeDescription(inputValueData);
|
|
1429
|
-
inputValueData.node.directives = this.getRouterPersistedDirectiveNodes(inputValueData);
|
|
1430
|
-
if (inputValueData.includeDefaultValue) {
|
|
1431
|
-
inputValueData.node.defaultValue = inputValueData.defaultValue;
|
|
1432
|
-
}
|
|
1433
|
-
return inputValueData.node;
|
|
1434
|
-
}
|
|
1435
1447
|
getValidFieldArgumentNodes(fieldData) {
|
|
1436
1448
|
const argumentNodes = [];
|
|
1437
1449
|
const argumentNames = [];
|
|
1438
1450
|
const invalidRequiredArguments = [];
|
|
1439
|
-
const
|
|
1451
|
+
const fieldCoords = `${fieldData.renamedParentTypeName}.${fieldData.name}`;
|
|
1440
1452
|
for (const [argumentName, inputValueData] of fieldData.argumentDataByName) {
|
|
1441
1453
|
if (fieldData.subgraphNames.size === inputValueData.subgraphNames.size) {
|
|
1442
1454
|
argumentNames.push(argumentName);
|
|
1443
|
-
|
|
1455
|
+
const argumentNodeResult = (0, utils_5.routerSchemaInputValueNodeFromData)({
|
|
1456
|
+
data: inputValueData,
|
|
1457
|
+
description: this.getFederatedGraphNodeDescription(inputValueData),
|
|
1458
|
+
federatedDirectiveDataByName: this.federatedDirectiveDataByName,
|
|
1459
|
+
parentDefinitionDataByTypeName: this.parentDefinitionDataByTypeName,
|
|
1460
|
+
});
|
|
1461
|
+
if (argumentNodeResult.success) {
|
|
1462
|
+
argumentNodes.push(argumentNodeResult.node);
|
|
1463
|
+
this.warnings.push(...argumentNodeResult.warnings);
|
|
1464
|
+
}
|
|
1465
|
+
else {
|
|
1466
|
+
this.errors.push(...argumentNodeResult.errors);
|
|
1467
|
+
}
|
|
1444
1468
|
}
|
|
1445
1469
|
else if ((0, utils_5.isTypeRequired)(inputValueData.type)) {
|
|
1446
1470
|
invalidRequiredArguments.push({
|
|
@@ -1451,11 +1475,11 @@ class FederationFactory {
|
|
|
1451
1475
|
}
|
|
1452
1476
|
}
|
|
1453
1477
|
if (invalidRequiredArguments.length > 0) {
|
|
1454
|
-
this.errors.push((0, errors_1.invalidRequiredInputValueError)(string_constants_1.FIELD,
|
|
1478
|
+
this.errors.push((0, errors_1.invalidRequiredInputValueError)(string_constants_1.FIELD, fieldCoords, invalidRequiredArguments));
|
|
1455
1479
|
}
|
|
1456
1480
|
else if (argumentNames.length > 0) {
|
|
1457
1481
|
// fieldConfiguration might already exist through subscriptionFilter
|
|
1458
|
-
(0, utils_6.getValueOrDefault)(this.fieldConfigurationByFieldCoords,
|
|
1482
|
+
(0, utils_6.getValueOrDefault)(this.fieldConfigurationByFieldCoords, fieldCoords, () => ({
|
|
1459
1483
|
argumentNames,
|
|
1460
1484
|
fieldName: fieldData.name,
|
|
1461
1485
|
typeName: fieldData.renamedParentTypeName,
|
|
@@ -1463,14 +1487,6 @@ class FederationFactory {
|
|
|
1463
1487
|
}
|
|
1464
1488
|
return argumentNodes;
|
|
1465
1489
|
}
|
|
1466
|
-
getNodeWithPersistedDirectivesByFieldData(fieldData, argumentNodes) {
|
|
1467
|
-
fieldData.node.arguments = argumentNodes;
|
|
1468
|
-
fieldData.node.name = (0, utils_1.stringToNameNode)(fieldData.name);
|
|
1469
|
-
fieldData.node.type = fieldData.type;
|
|
1470
|
-
fieldData.node.description = this.getFederatedGraphNodeDescription(fieldData);
|
|
1471
|
-
fieldData.node.directives = this.getRouterPersistedDirectiveNodes(fieldData);
|
|
1472
|
-
return fieldData.node;
|
|
1473
|
-
}
|
|
1474
1490
|
validateSemanticNonNull(data) {
|
|
1475
1491
|
let comparison;
|
|
1476
1492
|
for (const levels of data.nullLevelsBySubgraphName.values()) {
|
|
@@ -1525,32 +1541,41 @@ class FederationFactory {
|
|
|
1525
1541
|
const mergeMethod = this.getEnumValueMergeMethod(parentTypeName);
|
|
1526
1542
|
(0, utils_5.propagateAuthDirectives)(parentDefinitionData, this.authorizationDataByParentTypeName.get(parentTypeName));
|
|
1527
1543
|
for (const enumValueData of parentDefinitionData.enumValueDataByName.values()) {
|
|
1528
|
-
const enumValueNode = this.getNodeForRouterSchemaByData(enumValueData);
|
|
1529
1544
|
const isValueInaccessible = (0, utils_5.isNodeDataInaccessible)(enumValueData);
|
|
1530
1545
|
const clientEnumValueNode = {
|
|
1531
1546
|
...enumValueData.node,
|
|
1532
|
-
directives: (0, utils_5.
|
|
1547
|
+
directives: (0, utils_5.getClientFederatedDirectiveNodes)(enumValueData),
|
|
1533
1548
|
};
|
|
1549
|
+
const enumValueNodeResult = (0, utils_5.routerSchemaNodeFromData)({
|
|
1550
|
+
data: enumValueData,
|
|
1551
|
+
description: this.getFederatedGraphNodeDescription(enumValueData),
|
|
1552
|
+
federatedDirectiveDataByName: this.federatedDirectiveDataByName,
|
|
1553
|
+
parentDefinitionDataByTypeName: this.parentDefinitionDataByTypeName,
|
|
1554
|
+
});
|
|
1555
|
+
if (!enumValueNodeResult.success) {
|
|
1556
|
+
this.errors.push(...enumValueNodeResult.errors);
|
|
1557
|
+
continue;
|
|
1558
|
+
}
|
|
1534
1559
|
switch (mergeMethod) {
|
|
1535
1560
|
case utils_5.MergeMethod.CONSISTENT:
|
|
1536
1561
|
if (!isValueInaccessible && parentDefinitionData.appearances > enumValueData.appearances) {
|
|
1537
1562
|
this.errors.push((0, errors_1.incompatibleSharedEnumError)(parentTypeName));
|
|
1538
1563
|
}
|
|
1539
|
-
enumValueNodes.push(
|
|
1564
|
+
enumValueNodes.push(enumValueNodeResult.node);
|
|
1540
1565
|
if (!isValueInaccessible) {
|
|
1541
1566
|
clientEnumValueNodes.push(clientEnumValueNode);
|
|
1542
1567
|
}
|
|
1543
1568
|
break;
|
|
1544
1569
|
case utils_5.MergeMethod.INTERSECTION:
|
|
1545
1570
|
if (parentDefinitionData.appearances === enumValueData.appearances) {
|
|
1546
|
-
enumValueNodes.push(
|
|
1571
|
+
enumValueNodes.push(enumValueNodeResult.node);
|
|
1547
1572
|
if (!isValueInaccessible) {
|
|
1548
1573
|
clientEnumValueNodes.push(clientEnumValueNode);
|
|
1549
1574
|
}
|
|
1550
1575
|
}
|
|
1551
1576
|
break;
|
|
1552
1577
|
default:
|
|
1553
|
-
enumValueNodes.push(
|
|
1578
|
+
enumValueNodes.push(enumValueNodeResult.node);
|
|
1554
1579
|
if (!isValueInaccessible) {
|
|
1555
1580
|
clientEnumValueNodes.push(clientEnumValueNode);
|
|
1556
1581
|
}
|
|
@@ -1558,7 +1583,18 @@ class FederationFactory {
|
|
|
1558
1583
|
}
|
|
1559
1584
|
}
|
|
1560
1585
|
parentDefinitionData.node.values = enumValueNodes;
|
|
1561
|
-
|
|
1586
|
+
const nodeResult = (0, utils_5.routerSchemaNodeFromData)({
|
|
1587
|
+
data: parentDefinitionData,
|
|
1588
|
+
description: this.getFederatedGraphNodeDescription(parentDefinitionData),
|
|
1589
|
+
federatedDirectiveDataByName: this.federatedDirectiveDataByName,
|
|
1590
|
+
parentDefinitionDataByTypeName: this.parentDefinitionDataByTypeName,
|
|
1591
|
+
});
|
|
1592
|
+
if (nodeResult.success) {
|
|
1593
|
+
this.routerDefinitions.push(nodeResult.node);
|
|
1594
|
+
}
|
|
1595
|
+
else {
|
|
1596
|
+
this.errors.push(...nodeResult.errors);
|
|
1597
|
+
}
|
|
1562
1598
|
if ((0, utils_5.isNodeDataInaccessible)(parentDefinitionData)) {
|
|
1563
1599
|
this.validateReferencesOfInaccessibleType(parentDefinitionData);
|
|
1564
1600
|
this.internalGraph.setNodeInaccessible(parentDefinitionData.name);
|
|
@@ -1570,7 +1606,7 @@ class FederationFactory {
|
|
|
1570
1606
|
}
|
|
1571
1607
|
this.clientDefinitions.push({
|
|
1572
1608
|
...parentDefinitionData.node,
|
|
1573
|
-
directives: (0, utils_5.
|
|
1609
|
+
directives: (0, utils_5.getClientFederatedDirectiveNodes)(parentDefinitionData),
|
|
1574
1610
|
values: clientEnumValueNodes,
|
|
1575
1611
|
});
|
|
1576
1612
|
break;
|
|
@@ -1588,13 +1624,25 @@ class FederationFactory {
|
|
|
1588
1624
|
requiredFieldNames.add(inputValueName);
|
|
1589
1625
|
}
|
|
1590
1626
|
if (parentDefinitionData.subgraphNames.size === inputValueData.subgraphNames.size) {
|
|
1591
|
-
|
|
1627
|
+
const inputValueNodeResult = (0, utils_5.routerSchemaInputValueNodeFromData)({
|
|
1628
|
+
data: inputValueData,
|
|
1629
|
+
description: this.getFederatedGraphNodeDescription(inputValueData),
|
|
1630
|
+
federatedDirectiveDataByName: this.federatedDirectiveDataByName,
|
|
1631
|
+
parentDefinitionDataByTypeName: this.parentDefinitionDataByTypeName,
|
|
1632
|
+
});
|
|
1633
|
+
if (inputValueNodeResult.success) {
|
|
1634
|
+
inputValueNodes.push(inputValueNodeResult.node);
|
|
1635
|
+
this.warnings.push(...inputValueNodeResult.warnings);
|
|
1636
|
+
}
|
|
1637
|
+
else {
|
|
1638
|
+
this.errors.push(...inputValueNodeResult.errors);
|
|
1639
|
+
}
|
|
1592
1640
|
if ((0, utils_5.isNodeDataInaccessible)(inputValueData)) {
|
|
1593
1641
|
continue;
|
|
1594
1642
|
}
|
|
1595
1643
|
clientInputValueNodes.push({
|
|
1596
1644
|
...inputValueData.node,
|
|
1597
|
-
directives: (0, utils_5.
|
|
1645
|
+
directives: (0, utils_5.getClientFederatedDirectiveNodes)(inputValueData),
|
|
1598
1646
|
});
|
|
1599
1647
|
}
|
|
1600
1648
|
else if ((0, utils_5.isTypeRequired)(inputValueData.type)) {
|
|
@@ -1617,7 +1665,18 @@ class FederationFactory {
|
|
|
1617
1665
|
break;
|
|
1618
1666
|
}
|
|
1619
1667
|
parentDefinitionData.node.fields = inputValueNodes;
|
|
1620
|
-
|
|
1668
|
+
const inputObjectNodeResult = (0, utils_5.routerSchemaNodeFromData)({
|
|
1669
|
+
data: parentDefinitionData,
|
|
1670
|
+
description: this.getFederatedGraphNodeDescription(parentDefinitionData),
|
|
1671
|
+
federatedDirectiveDataByName: this.federatedDirectiveDataByName,
|
|
1672
|
+
parentDefinitionDataByTypeName: this.parentDefinitionDataByTypeName,
|
|
1673
|
+
});
|
|
1674
|
+
if (inputObjectNodeResult.success) {
|
|
1675
|
+
this.routerDefinitions.push(inputObjectNodeResult.node);
|
|
1676
|
+
}
|
|
1677
|
+
else {
|
|
1678
|
+
this.errors.push(...inputObjectNodeResult.errors);
|
|
1679
|
+
}
|
|
1621
1680
|
if ((0, utils_5.isNodeDataInaccessible)(parentDefinitionData)) {
|
|
1622
1681
|
this.validateReferencesOfInaccessibleType(parentDefinitionData);
|
|
1623
1682
|
break;
|
|
@@ -1628,7 +1687,7 @@ class FederationFactory {
|
|
|
1628
1687
|
}
|
|
1629
1688
|
this.clientDefinitions.push({
|
|
1630
1689
|
...parentDefinitionData.node,
|
|
1631
|
-
directives: (0, utils_5.
|
|
1690
|
+
directives: (0, utils_5.getClientFederatedDirectiveNodes)(parentDefinitionData),
|
|
1632
1691
|
fields: clientInputValueNodes,
|
|
1633
1692
|
});
|
|
1634
1693
|
break;
|
|
@@ -1650,7 +1709,20 @@ class FederationFactory {
|
|
|
1650
1709
|
(0, utils_5.validateExternalAndShareable)(fieldData, invalidFieldNames);
|
|
1651
1710
|
}
|
|
1652
1711
|
this.validateSemanticNonNull(fieldData);
|
|
1653
|
-
|
|
1712
|
+
const fieldNodeResult = (0, utils_5.routerSchemaFieldNodeFromData)({
|
|
1713
|
+
argumentNodes,
|
|
1714
|
+
data: fieldData,
|
|
1715
|
+
description: this.getFederatedGraphNodeDescription(fieldData),
|
|
1716
|
+
federatedDirectiveDataByName: this.federatedDirectiveDataByName,
|
|
1717
|
+
parentDefinitionDataByTypeName: this.parentDefinitionDataByTypeName,
|
|
1718
|
+
});
|
|
1719
|
+
if (!fieldNodeResult.success) {
|
|
1720
|
+
this.errors.push(...fieldNodeResult.errors);
|
|
1721
|
+
}
|
|
1722
|
+
else {
|
|
1723
|
+
fieldNodes.push(fieldNodeResult.node);
|
|
1724
|
+
this.warnings.push(...fieldNodeResult.warnings);
|
|
1725
|
+
}
|
|
1654
1726
|
if ((0, utils_5.isNodeDataInaccessible)(fieldData)) {
|
|
1655
1727
|
continue;
|
|
1656
1728
|
}
|
|
@@ -1672,7 +1744,18 @@ class FederationFactory {
|
|
|
1672
1744
|
interfaceImplementations.push({ data: parentDefinitionData, clientSchemaFieldNodes });
|
|
1673
1745
|
break;
|
|
1674
1746
|
}
|
|
1675
|
-
|
|
1747
|
+
const nodeResult = (0, utils_5.routerSchemaNodeFromData)({
|
|
1748
|
+
data: parentDefinitionData,
|
|
1749
|
+
description: this.getFederatedGraphNodeDescription(parentDefinitionData),
|
|
1750
|
+
federatedDirectiveDataByName: this.federatedDirectiveDataByName,
|
|
1751
|
+
parentDefinitionDataByTypeName: this.parentDefinitionDataByTypeName,
|
|
1752
|
+
});
|
|
1753
|
+
if (nodeResult.success) {
|
|
1754
|
+
this.routerDefinitions.push(nodeResult.node);
|
|
1755
|
+
}
|
|
1756
|
+
else {
|
|
1757
|
+
this.errors.push(...nodeResult.errors);
|
|
1758
|
+
}
|
|
1676
1759
|
const isQuery = (0, utils_4.isNodeQuery)(parentTypeName);
|
|
1677
1760
|
if ((0, utils_5.isNodeDataInaccessible)(parentDefinitionData)) {
|
|
1678
1761
|
if (isQuery) {
|
|
@@ -1692,7 +1775,7 @@ class FederationFactory {
|
|
|
1692
1775
|
}
|
|
1693
1776
|
this.clientDefinitions.push({
|
|
1694
1777
|
...parentDefinitionData.node,
|
|
1695
|
-
directives: (0, utils_5.
|
|
1778
|
+
directives: (0, utils_5.getClientFederatedDirectiveNodes)(parentDefinitionData),
|
|
1696
1779
|
fields: clientSchemaFieldNodes,
|
|
1697
1780
|
});
|
|
1698
1781
|
break;
|
|
@@ -1702,7 +1785,18 @@ class FederationFactory {
|
|
|
1702
1785
|
break;
|
|
1703
1786
|
}
|
|
1704
1787
|
(0, utils_5.propagateAuthDirectives)(parentDefinitionData, this.authorizationDataByParentTypeName.get(parentTypeName));
|
|
1705
|
-
|
|
1788
|
+
const nodeResult = (0, utils_5.routerSchemaNodeFromData)({
|
|
1789
|
+
data: parentDefinitionData,
|
|
1790
|
+
description: this.getFederatedGraphNodeDescription(parentDefinitionData),
|
|
1791
|
+
federatedDirectiveDataByName: this.federatedDirectiveDataByName,
|
|
1792
|
+
parentDefinitionDataByTypeName: this.parentDefinitionDataByTypeName,
|
|
1793
|
+
});
|
|
1794
|
+
if (nodeResult.success) {
|
|
1795
|
+
this.routerDefinitions.push(nodeResult.node);
|
|
1796
|
+
}
|
|
1797
|
+
else {
|
|
1798
|
+
this.errors.push(...nodeResult.errors);
|
|
1799
|
+
}
|
|
1706
1800
|
if ((0, utils_5.isNodeDataInaccessible)(parentDefinitionData)) {
|
|
1707
1801
|
this.validateReferencesOfInaccessibleType(parentDefinitionData);
|
|
1708
1802
|
this.internalGraph.setNodeInaccessible(parentDefinitionData.name);
|
|
@@ -1710,13 +1804,24 @@ class FederationFactory {
|
|
|
1710
1804
|
}
|
|
1711
1805
|
this.clientDefinitions.push({
|
|
1712
1806
|
...parentDefinitionData.node,
|
|
1713
|
-
directives: (0, utils_5.
|
|
1807
|
+
directives: (0, utils_5.getClientFederatedDirectiveNodes)(parentDefinitionData),
|
|
1714
1808
|
});
|
|
1715
1809
|
break;
|
|
1716
1810
|
}
|
|
1717
1811
|
case graphql_1.Kind.UNION_TYPE_DEFINITION: {
|
|
1718
1812
|
parentDefinitionData.node.types = (0, utils_3.mapToArrayOfValues)(parentDefinitionData.memberByMemberTypeName);
|
|
1719
|
-
|
|
1813
|
+
const nodeResult = (0, utils_5.routerSchemaNodeFromData)({
|
|
1814
|
+
data: parentDefinitionData,
|
|
1815
|
+
description: this.getFederatedGraphNodeDescription(parentDefinitionData),
|
|
1816
|
+
federatedDirectiveDataByName: this.federatedDirectiveDataByName,
|
|
1817
|
+
parentDefinitionDataByTypeName: this.parentDefinitionDataByTypeName,
|
|
1818
|
+
});
|
|
1819
|
+
if (nodeResult.success) {
|
|
1820
|
+
this.routerDefinitions.push(nodeResult.node);
|
|
1821
|
+
}
|
|
1822
|
+
else {
|
|
1823
|
+
this.errors.push(...nodeResult.errors);
|
|
1824
|
+
}
|
|
1720
1825
|
if ((0, utils_5.isNodeDataInaccessible)(parentDefinitionData)) {
|
|
1721
1826
|
this.validateReferencesOfInaccessibleType(parentDefinitionData);
|
|
1722
1827
|
this.internalGraph.setNodeInaccessible(parentDefinitionData.name);
|
|
@@ -1729,7 +1834,7 @@ class FederationFactory {
|
|
|
1729
1834
|
}
|
|
1730
1835
|
this.clientDefinitions.push({
|
|
1731
1836
|
...parentDefinitionData.node,
|
|
1732
|
-
directives: (0, utils_5.
|
|
1837
|
+
directives: (0, utils_5.getClientFederatedDirectiveNodes)(parentDefinitionData),
|
|
1733
1838
|
types: clientMembers,
|
|
1734
1839
|
});
|
|
1735
1840
|
break;
|
|
@@ -1783,7 +1888,18 @@ class FederationFactory {
|
|
|
1783
1888
|
validateInterfaceImplementationsAndPushToDocumentDefinitions(interfaceImplementations) {
|
|
1784
1889
|
for (const { data, clientSchemaFieldNodes } of interfaceImplementations) {
|
|
1785
1890
|
data.node.interfaces = this.getValidImplementedInterfaces(data);
|
|
1786
|
-
|
|
1891
|
+
const nodeResult = (0, utils_5.routerSchemaNodeFromData)({
|
|
1892
|
+
data,
|
|
1893
|
+
description: this.getFederatedGraphNodeDescription(data),
|
|
1894
|
+
federatedDirectiveDataByName: this.federatedDirectiveDataByName,
|
|
1895
|
+
parentDefinitionDataByTypeName: this.parentDefinitionDataByTypeName,
|
|
1896
|
+
});
|
|
1897
|
+
if (nodeResult.success) {
|
|
1898
|
+
this.routerDefinitions.push(nodeResult.node);
|
|
1899
|
+
}
|
|
1900
|
+
else {
|
|
1901
|
+
this.errors.push(...nodeResult.errors);
|
|
1902
|
+
}
|
|
1787
1903
|
if ((0, utils_5.isNodeDataInaccessible)(data)) {
|
|
1788
1904
|
this.validateReferencesOfInaccessibleType(data);
|
|
1789
1905
|
this.internalGraph.setNodeInaccessible(data.name);
|
|
@@ -1800,7 +1916,7 @@ class FederationFactory {
|
|
|
1800
1916
|
* */
|
|
1801
1917
|
this.clientDefinitions.push({
|
|
1802
1918
|
...data.node,
|
|
1803
|
-
directives: (0, utils_5.
|
|
1919
|
+
directives: (0, utils_5.getClientFederatedDirectiveNodes)(data),
|
|
1804
1920
|
fields: clientSchemaFieldNodes,
|
|
1805
1921
|
interfaces: clientInterfaces,
|
|
1806
1922
|
});
|
|
@@ -1809,14 +1925,14 @@ class FederationFactory {
|
|
|
1809
1925
|
#addDirectiveDefinitionsAndDepsToRouterAndClientSchemas() {
|
|
1810
1926
|
const clientDependencies = new Set();
|
|
1811
1927
|
const routerDependencies = new Set();
|
|
1812
|
-
for (const directiveName of this.
|
|
1928
|
+
for (const directiveName of this.referencedFederatedDirectiveNames) {
|
|
1813
1929
|
const definition = constants_1.DIRECTIVE_DEFINITION_BY_NAME.get(directiveName);
|
|
1814
1930
|
if (!definition) {
|
|
1815
1931
|
continue;
|
|
1816
1932
|
}
|
|
1817
1933
|
const dependencies = strings_1.DEPENDENCIES_BY_DIRECTIVE_NAME.get(directiveName) ?? [];
|
|
1818
1934
|
this.directiveDefinitionByName.set(directiveName, definition);
|
|
1819
|
-
if (strings_1.
|
|
1935
|
+
if (strings_1.CLIENT_FEDERATED_DIRECTIVE_NAMES.has(directiveName)) {
|
|
1820
1936
|
this.clientDefinitions.push(definition);
|
|
1821
1937
|
(0, utils_6.addIterableToSet)({
|
|
1822
1938
|
source: dependencies,
|
|
@@ -2158,9 +2274,7 @@ class FederationFactory {
|
|
|
2158
2274
|
if (this.invalidORScopesCoords.size > 0) {
|
|
2159
2275
|
this.errors.push((0, errors_1.orScopesLimitError)(constants_1.MAX_OR_SCOPES, [...this.invalidORScopesCoords]));
|
|
2160
2276
|
}
|
|
2161
|
-
|
|
2162
|
-
(0, utils_5.addValidPersistedDirectiveDefinitionNodeByData)(this.routerDefinitions, data, this.persistedDirectiveDefinitionByDirectiveName, this.errors);
|
|
2163
|
-
}
|
|
2277
|
+
this.handleCustomDirectiveDefinitionNodes();
|
|
2164
2278
|
const definitionsWithInterfaces = [];
|
|
2165
2279
|
this.pushParentDefinitionDataToDocumentDefinitions(definitionsWithInterfaces);
|
|
2166
2280
|
this.validateInterfaceImplementationsAndPushToDocumentDefinitions(definitionsWithInterfaces);
|
|
@@ -2242,7 +2356,7 @@ class FederationFactory {
|
|
|
2242
2356
|
continue;
|
|
2243
2357
|
}
|
|
2244
2358
|
if (!tagNames.isDisjointFrom(childTagData.tagNames)) {
|
|
2245
|
-
(0, utils_6.getValueOrDefault)(childData.
|
|
2359
|
+
(0, utils_6.getValueOrDefault)(childData.federatedDirectivesData.directivesByName, string_constants_1.INACCESSIBLE, () => [
|
|
2246
2360
|
(0, utils_6.generateSimpleDirective)(string_constants_1.INACCESSIBLE),
|
|
2247
2361
|
]);
|
|
2248
2362
|
this.inaccessibleCoords.add(`${parentDefinitionData.name}.${childName}`);
|
|
@@ -2250,7 +2364,7 @@ class FederationFactory {
|
|
|
2250
2364
|
}
|
|
2251
2365
|
}
|
|
2252
2366
|
if (accessibleChildren < 1) {
|
|
2253
|
-
parentDefinitionData.
|
|
2367
|
+
parentDefinitionData.federatedDirectivesData.directivesByName.set(string_constants_1.INACCESSIBLE, [
|
|
2254
2368
|
(0, utils_6.generateSimpleDirective)(string_constants_1.INACCESSIBLE),
|
|
2255
2369
|
]);
|
|
2256
2370
|
this.inaccessibleCoords.add(parentDefinitionData.name);
|
|
@@ -2265,7 +2379,7 @@ class FederationFactory {
|
|
|
2265
2379
|
}
|
|
2266
2380
|
const childTagData = childTagDataByChildName.get(childName);
|
|
2267
2381
|
if (!childTagData || tagNames.isDisjointFrom(childTagData.tagNames)) {
|
|
2268
|
-
(0, utils_6.getValueOrDefault)(childData.
|
|
2382
|
+
(0, utils_6.getValueOrDefault)(childData.federatedDirectivesData.directivesByName, string_constants_1.INACCESSIBLE, () => [
|
|
2269
2383
|
(0, utils_6.generateSimpleDirective)(string_constants_1.INACCESSIBLE),
|
|
2270
2384
|
]);
|
|
2271
2385
|
this.inaccessibleCoords.add(`${parentDefinitionData.name}.${childName}`);
|
|
@@ -2273,12 +2387,29 @@ class FederationFactory {
|
|
|
2273
2387
|
}
|
|
2274
2388
|
}
|
|
2275
2389
|
if (accessibleChildren < 1) {
|
|
2276
|
-
parentDefinitionData.
|
|
2390
|
+
parentDefinitionData.federatedDirectivesData.directivesByName.set(string_constants_1.INACCESSIBLE, [
|
|
2277
2391
|
(0, utils_6.generateSimpleDirective)(string_constants_1.INACCESSIBLE),
|
|
2278
2392
|
]);
|
|
2279
2393
|
this.inaccessibleCoords.add(parentDefinitionData.name);
|
|
2280
2394
|
}
|
|
2281
2395
|
}
|
|
2396
|
+
handleCustomDirectiveDefinitionNodes() {
|
|
2397
|
+
for (const data of this.federatedDirectiveDataByName.values()) {
|
|
2398
|
+
if (!data.isComposed && data.executableLocations.size < 1) {
|
|
2399
|
+
continue;
|
|
2400
|
+
}
|
|
2401
|
+
const directiveNodeResult = (0, utils_5.propagateDirectiveDefinitionNodeFromData)({
|
|
2402
|
+
data,
|
|
2403
|
+
federatedDirectiveDataByName: this.federatedDirectiveDataByName,
|
|
2404
|
+
parentDefinitionDataByTypeName: this.parentDefinitionDataByTypeName,
|
|
2405
|
+
});
|
|
2406
|
+
if (!directiveNodeResult.success) {
|
|
2407
|
+
this.errors.push(...directiveNodeResult.errors);
|
|
2408
|
+
continue;
|
|
2409
|
+
}
|
|
2410
|
+
this.routerDefinitions.push(data.node);
|
|
2411
|
+
}
|
|
2412
|
+
}
|
|
2282
2413
|
buildFederationContractResult(contractTagOptions) {
|
|
2283
2414
|
if (!this.isVersionTwo) {
|
|
2284
2415
|
/* If all the subgraphs are version one, the @inaccessible directive won't be present.
|
|
@@ -2292,7 +2423,7 @@ class FederationFactory {
|
|
|
2292
2423
|
continue;
|
|
2293
2424
|
}
|
|
2294
2425
|
if (!contractTagOptions.tagNamesToExclude.isDisjointFrom(parentTagData.tagNames)) {
|
|
2295
|
-
parentDefinitionData.
|
|
2426
|
+
parentDefinitionData.federatedDirectivesData.directivesByName.set(string_constants_1.INACCESSIBLE, [
|
|
2296
2427
|
(0, utils_6.generateSimpleDirective)(string_constants_1.INACCESSIBLE),
|
|
2297
2428
|
]);
|
|
2298
2429
|
this.inaccessibleCoords.add(parentTypeName);
|
|
@@ -2325,7 +2456,7 @@ class FederationFactory {
|
|
|
2325
2456
|
continue;
|
|
2326
2457
|
}
|
|
2327
2458
|
if (!contractTagOptions.tagNamesToExclude.isDisjointFrom(childTagData.tagNames)) {
|
|
2328
|
-
(0, utils_6.getValueOrDefault)(fieldData.
|
|
2459
|
+
(0, utils_6.getValueOrDefault)(fieldData.federatedDirectivesData.directivesByName, string_constants_1.INACCESSIBLE, () => [
|
|
2329
2460
|
(0, utils_6.generateSimpleDirective)(string_constants_1.INACCESSIBLE),
|
|
2330
2461
|
]);
|
|
2331
2462
|
this.inaccessibleCoords.add(fieldData.federatedCoords);
|
|
@@ -2338,7 +2469,7 @@ class FederationFactory {
|
|
|
2338
2469
|
continue;
|
|
2339
2470
|
}
|
|
2340
2471
|
if (!contractTagOptions.tagNamesToExclude.isDisjointFrom(argTagNames)) {
|
|
2341
|
-
(0, utils_6.getValueOrDefault)(inputValueData.
|
|
2472
|
+
(0, utils_6.getValueOrDefault)(inputValueData.federatedDirectivesData.directivesByName, string_constants_1.INACCESSIBLE, () => [
|
|
2342
2473
|
(0, utils_6.generateSimpleDirective)(string_constants_1.INACCESSIBLE),
|
|
2343
2474
|
]);
|
|
2344
2475
|
this.inaccessibleCoords.add(inputValueData.federatedCoords);
|
|
@@ -2346,7 +2477,7 @@ class FederationFactory {
|
|
|
2346
2477
|
}
|
|
2347
2478
|
}
|
|
2348
2479
|
if (accessibleFields < 1) {
|
|
2349
|
-
parentDefinitionData.
|
|
2480
|
+
parentDefinitionData.federatedDirectivesData.directivesByName.set(string_constants_1.INACCESSIBLE, [
|
|
2350
2481
|
(0, utils_6.generateSimpleDirective)(string_constants_1.INACCESSIBLE),
|
|
2351
2482
|
]);
|
|
2352
2483
|
this.inaccessibleCoords.add(parentTypeName);
|
|
@@ -2362,7 +2493,7 @@ class FederationFactory {
|
|
|
2362
2493
|
}
|
|
2363
2494
|
const parentTagData = this.parentTagDataByTypeName.get(parentTypeName);
|
|
2364
2495
|
if (!parentTagData) {
|
|
2365
|
-
parentDefinitionData.
|
|
2496
|
+
parentDefinitionData.federatedDirectivesData.directivesByName.set(string_constants_1.INACCESSIBLE, [
|
|
2366
2497
|
(0, utils_6.generateSimpleDirective)(string_constants_1.INACCESSIBLE),
|
|
2367
2498
|
]);
|
|
2368
2499
|
this.inaccessibleCoords.add(parentTypeName);
|
|
@@ -2373,7 +2504,7 @@ class FederationFactory {
|
|
|
2373
2504
|
continue;
|
|
2374
2505
|
}
|
|
2375
2506
|
if (parentTagData.childTagDataByChildName.size < 1) {
|
|
2376
|
-
parentDefinitionData.
|
|
2507
|
+
parentDefinitionData.federatedDirectivesData.directivesByName.set(string_constants_1.INACCESSIBLE, [
|
|
2377
2508
|
(0, utils_6.generateSimpleDirective)(string_constants_1.INACCESSIBLE),
|
|
2378
2509
|
]);
|
|
2379
2510
|
this.inaccessibleCoords.add(parentTypeName);
|
|
@@ -2400,7 +2531,7 @@ class FederationFactory {
|
|
|
2400
2531
|
}
|
|
2401
2532
|
const childTagData = parentTagData.childTagDataByChildName.get(fieldName);
|
|
2402
2533
|
if (!childTagData || contractTagOptions.tagNamesToInclude.isDisjointFrom(childTagData.tagNames)) {
|
|
2403
|
-
(0, utils_6.getValueOrDefault)(fieldData.
|
|
2534
|
+
(0, utils_6.getValueOrDefault)(fieldData.federatedDirectivesData.directivesByName, string_constants_1.INACCESSIBLE, () => [
|
|
2404
2535
|
(0, utils_6.generateSimpleDirective)(string_constants_1.INACCESSIBLE),
|
|
2405
2536
|
]);
|
|
2406
2537
|
this.inaccessibleCoords.add(fieldData.federatedCoords);
|
|
@@ -2408,7 +2539,7 @@ class FederationFactory {
|
|
|
2408
2539
|
}
|
|
2409
2540
|
}
|
|
2410
2541
|
if (accessibleFields < 1) {
|
|
2411
|
-
parentDefinitionData.
|
|
2542
|
+
parentDefinitionData.federatedDirectivesData.directivesByName.set(string_constants_1.INACCESSIBLE, [
|
|
2412
2543
|
(0, utils_6.generateSimpleDirective)(string_constants_1.INACCESSIBLE),
|
|
2413
2544
|
]);
|
|
2414
2545
|
this.inaccessibleCoords.add(parentTypeName);
|
|
@@ -2419,9 +2550,7 @@ class FederationFactory {
|
|
|
2419
2550
|
if (this.subscriptionFilterDataByFieldPath.size > 0) {
|
|
2420
2551
|
this.validateSubscriptionFiltersAndGenerateConfiguration();
|
|
2421
2552
|
}
|
|
2422
|
-
|
|
2423
|
-
(0, utils_5.addValidPersistedDirectiveDefinitionNodeByData)(this.routerDefinitions, data, this.persistedDirectiveDefinitionByDirectiveName, this.errors);
|
|
2424
|
-
}
|
|
2553
|
+
this.handleCustomDirectiveDefinitionNodes();
|
|
2425
2554
|
const interfaceImplementations = [];
|
|
2426
2555
|
this.pushParentDefinitionDataToDocumentDefinitions(interfaceImplementations);
|
|
2427
2556
|
this.validateInterfaceImplementationsAndPushToDocumentDefinitions(interfaceImplementations);
|
|
@@ -2475,14 +2604,14 @@ function initializeFederationFactory({ options, subgraphs }) {
|
|
|
2475
2604
|
if (subgraphs.length < 1) {
|
|
2476
2605
|
return { errors: [errors_1.minimumSubgraphRequirementError], success: false, warnings: [] };
|
|
2477
2606
|
}
|
|
2478
|
-
const result =
|
|
2607
|
+
const result = new batch_normalizer_1.BatchNormalizer({ subgraphs, options }).batchNormalize();
|
|
2479
2608
|
if (!result.success) {
|
|
2480
2609
|
return { errors: result.errors, success: false, warnings: result.warnings };
|
|
2481
2610
|
}
|
|
2482
2611
|
const entityInterfaceFederationDataByTypeName = new Map();
|
|
2483
2612
|
const invalidEntityInterfacesByTypeName = new Map();
|
|
2484
|
-
for (const [subgraphName, internalSubgraph] of result.
|
|
2485
|
-
for (const [typeName, entityInterfaceData] of internalSubgraph.
|
|
2613
|
+
for (const [subgraphName, internalSubgraph] of result.internalSubgraphByName) {
|
|
2614
|
+
for (const [typeName, entityInterfaceData] of internalSubgraph.entityInterfaceSubgraphDataByTypeName) {
|
|
2486
2615
|
const existingData = entityInterfaceFederationDataByTypeName.get(typeName);
|
|
2487
2616
|
if (!existingData) {
|
|
2488
2617
|
entityInterfaceFederationDataByTypeName.set(typeName, (0, utils_3.newEntityInterfaceFederationData)(entityInterfaceData, subgraphName));
|
|
@@ -2515,7 +2644,7 @@ function initializeFederationFactory({ options, subgraphs }) {
|
|
|
2515
2644
|
source: entityInterfaceData.concreteTypeNames,
|
|
2516
2645
|
target: definedConcreteTypeNames,
|
|
2517
2646
|
});
|
|
2518
|
-
const { parentDefinitionDataByTypeName } = (0, utils_6.getOrThrowError)(result.
|
|
2647
|
+
const { parentDefinitionDataByTypeName } = (0, utils_6.getOrThrowError)(result.internalSubgraphByName, subgraphName, 'internalSubgraphBySubgraphName');
|
|
2519
2648
|
const invalidTypeNames = [];
|
|
2520
2649
|
for (const concreteTypeName of entityInterfaceData.concreteTypeNames) {
|
|
2521
2650
|
if (parentDefinitionDataByTypeName.has(concreteTypeName)) {
|
|
@@ -2563,9 +2692,11 @@ function initializeFederationFactory({ options, subgraphs }) {
|
|
|
2563
2692
|
concreteTypeNamesByAbstractTypeName: result.concreteTypeNamesByAbstractTypeName,
|
|
2564
2693
|
entityDataByTypeName: result.entityDataByTypeName,
|
|
2565
2694
|
entityInterfaceFederationDataByTypeName,
|
|
2695
|
+
executableDirectiveDatasByName: result.executableDirectiveDatasByName,
|
|
2696
|
+
federatedDirectiveDataByName: result.federatedDirectiveDataByName,
|
|
2566
2697
|
fieldCoordsByNamedTypeName: result.fieldCoordsByNamedTypeName,
|
|
2567
2698
|
interfaceImplementationTypeNamesByInterfaceTypeName: result.interfaceImplementationTypeNamesByInterfaceTypeName,
|
|
2568
|
-
internalSubgraphBySubgraphName: result.
|
|
2699
|
+
internalSubgraphBySubgraphName: result.internalSubgraphByName,
|
|
2569
2700
|
internalGraph: result.internalGraph,
|
|
2570
2701
|
options,
|
|
2571
2702
|
warnings: result.warnings,
|