@wundergraph/composition 0.36.0 → 0.37.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/ast/utils.d.ts +0 -2
- package/dist/ast/utils.js +0 -31
- package/dist/ast/utils.js.map +1 -1
- package/dist/errors/errors.d.ts +3 -3
- package/dist/errors/errors.js +11 -7
- package/dist/errors/errors.js.map +1 -1
- package/dist/federation/federation.d.ts +6 -0
- package/dist/federation/federation.js +30 -0
- package/dist/federation/federation.js.map +1 -0
- package/dist/federation/types.d.ts +44 -0
- package/dist/federation/types.js +3 -0
- package/dist/federation/types.js.map +1 -0
- package/dist/index.d.ts +21 -13
- package/dist/index.js +22 -13
- package/dist/index.js.map +1 -1
- package/dist/normalization/normalization.d.ts +6 -0
- package/dist/normalization/normalization.js +21 -0
- package/dist/normalization/normalization.js.map +1 -0
- package/dist/normalization/types.d.ts +48 -0
- package/dist/normalization/types.js +3 -0
- package/dist/normalization/types.js.map +1 -0
- package/dist/resolvability-graph/graph.d.ts +2 -2
- package/dist/resolvability-graph/graph.js +21 -21
- package/dist/resolvability-graph/graph.js.map +1 -1
- package/dist/resolvability-graph/utils.js +2 -2
- package/dist/resolvability-graph/utils.js.map +1 -1
- package/dist/router-compatibility-version/router-compatibility-version.d.ts +4 -0
- package/dist/router-compatibility-version/router-compatibility-version.js +7 -0
- package/dist/router-compatibility-version/router-compatibility-version.js.map +1 -0
- package/dist/schema-building/ast.js.map +1 -1
- package/dist/schema-building/{type-definition-data.d.ts → types.d.ts} +34 -3
- package/dist/schema-building/{type-definition-data.js → types.js} +1 -1
- package/dist/schema-building/types.js.map +1 -0
- package/dist/schema-building/utils.d.ts +2 -7
- package/dist/schema-building/utils.js +5 -6
- package/dist/schema-building/utils.js.map +1 -1
- package/dist/subgraph/{subgraph.d.ts → types.d.ts} +5 -8
- package/dist/subgraph/types.js +3 -0
- package/dist/subgraph/types.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/utils/composition-version.js +1 -1
- package/dist/utils/integer-constants.d.ts +0 -1
- package/dist/utils/integer-constants.js +1 -2
- package/dist/utils/integer-constants.js.map +1 -1
- package/dist/utils/string-constants.d.ts +2 -7
- package/dist/utils/string-constants.js +3 -30
- package/dist/utils/string-constants.js.map +1 -1
- package/dist/utils/types.d.ts +1 -0
- package/dist/utils/types.js +3 -0
- package/dist/utils/types.js.map +1 -0
- package/dist/utils/utils.d.ts +10 -74
- package/dist/utils/utils.js +33 -386
- package/dist/utils/utils.js.map +1 -1
- package/dist/{federation → v1/federation}/federation-factory.d.ts +18 -17
- package/dist/{federation → v1/federation}/federation-factory.js +202 -199
- package/dist/v1/federation/federation-factory.js.map +1 -0
- package/dist/{federation → v1/federation}/utils.d.ts +11 -35
- package/dist/{federation → v1/federation}/utils.js +8 -8
- package/dist/v1/federation/utils.js.map +1 -0
- package/dist/{federation → v1/federation}/walkers.d.ts +1 -1
- package/dist/{federation → v1/federation}/walkers.js +10 -10
- package/dist/v1/federation/walkers.js.map +1 -0
- package/dist/{normalization → v1/normalization}/directive-definition-data.d.ts +1 -1
- package/dist/{normalization → v1/normalization}/directive-definition-data.js +2 -2
- package/dist/v1/normalization/directive-definition-data.js.map +1 -0
- package/dist/{normalization → v1/normalization}/normalization-factory.d.ts +29 -54
- package/dist/{normalization → v1/normalization}/normalization-factory.js +201 -202
- package/dist/v1/normalization/normalization-factory.js.map +1 -0
- package/dist/{normalization → v1/normalization}/utils.d.ts +2 -2
- package/dist/{normalization → v1/normalization}/utils.js +33 -34
- package/dist/v1/normalization/utils.js.map +1 -0
- package/dist/{normalization → v1/normalization}/walkers.js +37 -35
- package/dist/v1/normalization/walkers.js.map +1 -0
- package/dist/{schema-building → v1/schema-building}/type-merging.d.ts +1 -1
- package/dist/{schema-building → v1/schema-building}/type-merging.js +4 -4
- package/dist/v1/schema-building/type-merging.js.map +1 -0
- package/dist/v1/subgraph/subgraph.d.ts +1 -0
- package/dist/v1/subgraph/subgraph.js.map +1 -0
- package/dist/{utils → v1/utils}/constants.d.ts +1 -2
- package/dist/{utils → v1/utils}/constants.js +7 -8
- package/dist/v1/utils/constants.js.map +1 -0
- package/dist/v1/utils/integer-constants.d.ts +1 -0
- package/dist/v1/utils/integer-constants.js +5 -0
- package/dist/v1/utils/integer-constants.js.map +1 -0
- package/dist/v1/utils/string-constants.d.ts +5 -0
- package/dist/v1/utils/string-constants.js +32 -0
- package/dist/v1/utils/string-constants.js.map +1 -0
- package/dist/v1/utils/utils.d.ts +35 -0
- package/dist/v1/utils/utils.js +330 -0
- package/dist/v1/utils/utils.js.map +1 -0
- package/dist/v1/warnings/warnings.d.ts +9 -0
- package/dist/v1/warnings/warnings.js +104 -0
- package/dist/v1/warnings/warnings.js.map +1 -0
- package/dist/warnings/warnings.d.ts +0 -8
- package/dist/warnings/warnings.js +0 -100
- package/dist/warnings/warnings.js.map +1 -1
- package/package.json +2 -2
- package/dist/federation/federation-factory.js.map +0 -1
- package/dist/federation/utils.js.map +0 -1
- package/dist/federation/walkers.js.map +0 -1
- package/dist/normalization/directive-definition-data.js.map +0 -1
- package/dist/normalization/normalization-factory.js.map +0 -1
- package/dist/normalization/utils.js.map +0 -1
- package/dist/normalization/walkers.js.map +0 -1
- package/dist/schema-building/type-definition-data.js.map +0 -1
- package/dist/schema-building/type-merging.js.map +0 -1
- package/dist/subgraph/subgraph.js.map +0 -1
- package/dist/utils/constants.js.map +0 -1
- /package/dist/{normalization → v1/normalization}/walkers.d.ts +0 -0
- /package/dist/{subgraph → v1/subgraph}/subgraph.js +0 -0
|
@@ -5,9 +5,9 @@ exports.federateSubgraphs = federateSubgraphs;
|
|
|
5
5
|
exports.federateSubgraphsWithContracts = federateSubgraphsWithContracts;
|
|
6
6
|
exports.federateSubgraphsContract = federateSubgraphsContract;
|
|
7
7
|
const graphql_1 = require("graphql");
|
|
8
|
-
const ast_1 = require("
|
|
9
|
-
const utils_1 = require("
|
|
10
|
-
const errors_1 = require("
|
|
8
|
+
const ast_1 = require("../../schema-building/ast");
|
|
9
|
+
const utils_1 = require("../../ast/utils");
|
|
10
|
+
const errors_1 = require("../../errors/errors");
|
|
11
11
|
const utils_2 = require("./utils");
|
|
12
12
|
const string_constants_1 = require("../utils/string-constants");
|
|
13
13
|
const utils_3 = require("../utils/utils");
|
|
@@ -15,12 +15,14 @@ const merge_1 = require("@graphql-tools/merge");
|
|
|
15
15
|
const constants_1 = require("../utils/constants");
|
|
16
16
|
const normalization_factory_1 = require("../normalization/normalization-factory");
|
|
17
17
|
const utils_4 = require("../normalization/utils");
|
|
18
|
-
const
|
|
19
|
-
const utils_5 = require("
|
|
18
|
+
const types_1 = require("../../schema-building/types");
|
|
19
|
+
const utils_5 = require("../../schema-building/utils");
|
|
20
20
|
const walkers_1 = require("./walkers");
|
|
21
21
|
const lodash_1 = require("lodash");
|
|
22
22
|
const type_merging_1 = require("../schema-building/type-merging");
|
|
23
|
-
const
|
|
23
|
+
const string_constants_2 = require("../../utils/string-constants");
|
|
24
|
+
const integer_constants_1 = require("../../utils/integer-constants");
|
|
25
|
+
const utils_6 = require("../../utils/utils");
|
|
24
26
|
class FederationFactory {
|
|
25
27
|
authorizationDataByParentTypeName;
|
|
26
28
|
concreteTypeNamesByAbstractTypeName;
|
|
@@ -43,27 +45,27 @@ class FederationFactory {
|
|
|
43
45
|
parentTagDataByTypeName = new Map();
|
|
44
46
|
pathsByNamedTypeName = new Map();
|
|
45
47
|
persistedDirectiveDefinitionByDirectiveName = new Map([
|
|
46
|
-
[
|
|
47
|
-
[
|
|
48
|
-
[
|
|
49
|
-
[
|
|
50
|
-
[
|
|
48
|
+
[string_constants_2.AUTHENTICATED, constants_1.AUTHENTICATED_DEFINITION],
|
|
49
|
+
[string_constants_2.DEPRECATED, constants_1.DEPRECATED_DEFINITION],
|
|
50
|
+
[string_constants_2.INACCESSIBLE, constants_1.INACCESSIBLE_DEFINITION],
|
|
51
|
+
[string_constants_2.REQUIRES_SCOPES, constants_1.REQUIRES_SCOPES_DEFINITION],
|
|
52
|
+
[string_constants_2.TAG, constants_1.TAG_DEFINITION],
|
|
51
53
|
]);
|
|
52
|
-
persistedDirectiveDefinitions = new Set([
|
|
54
|
+
persistedDirectiveDefinitions = new Set([string_constants_2.AUTHENTICATED, string_constants_2.DEPRECATED, string_constants_2.INACCESSIBLE, string_constants_2.TAG, string_constants_2.REQUIRES_SCOPES]);
|
|
53
55
|
potentialPersistedDirectiveDefinitionDataByDirectiveName = new Map();
|
|
54
56
|
routerDefinitions = [constants_1.DEPRECATED_DEFINITION, constants_1.TAG_DEFINITION];
|
|
55
57
|
shareableErrorTypeNames = new Map();
|
|
56
58
|
subscriptionFilterDataByFieldPath = new Map();
|
|
57
59
|
tagNamesByPath = new Map();
|
|
58
60
|
warnings;
|
|
59
|
-
constructor(
|
|
60
|
-
this.authorizationDataByParentTypeName =
|
|
61
|
-
this.concreteTypeNamesByAbstractTypeName =
|
|
62
|
-
this.entityDataByTypeName =
|
|
63
|
-
this.entityInterfaceFederationDataByTypeName =
|
|
64
|
-
this.internalSubgraphBySubgraphName =
|
|
65
|
-
this.internalGraph =
|
|
66
|
-
this.warnings =
|
|
61
|
+
constructor(params) {
|
|
62
|
+
this.authorizationDataByParentTypeName = params.authorizationDataByParentTypeName;
|
|
63
|
+
this.concreteTypeNamesByAbstractTypeName = params.concreteTypeNamesByAbstractTypeName;
|
|
64
|
+
this.entityDataByTypeName = params.entityDataByTypeName;
|
|
65
|
+
this.entityInterfaceFederationDataByTypeName = params.entityInterfaceFederationDataByTypeName;
|
|
66
|
+
this.internalSubgraphBySubgraphName = params.internalSubgraphBySubgraphName;
|
|
67
|
+
this.internalGraph = params.internalGraph;
|
|
68
|
+
this.warnings = params.warnings;
|
|
67
69
|
}
|
|
68
70
|
getValidImplementedInterfaces(data) {
|
|
69
71
|
const interfaces = [];
|
|
@@ -75,9 +77,9 @@ class FederationFactory {
|
|
|
75
77
|
const invalidImplementationTypeStringByTypeName = new Map();
|
|
76
78
|
for (const interfaceName of data.implementedInterfaceTypeNames) {
|
|
77
79
|
interfaces.push((0, utils_1.stringToNamedTypeNode)(interfaceName));
|
|
78
|
-
const implementationData = (0,
|
|
80
|
+
const implementationData = (0, utils_6.getOrThrowError)(this.parentDefinitionDataByTypeName, interfaceName, string_constants_2.PARENT_DEFINITION_DATA);
|
|
79
81
|
if (implementationData.kind !== graphql_1.Kind.INTERFACE_TYPE_DEFINITION) {
|
|
80
|
-
invalidImplementationTypeStringByTypeName.set(implementationData.name, (0,
|
|
82
|
+
invalidImplementationTypeStringByTypeName.set(implementationData.name, (0, utils_6.kindToTypeString)(implementationData.kind));
|
|
81
83
|
continue;
|
|
82
84
|
}
|
|
83
85
|
const implementationErrors = {
|
|
@@ -157,7 +159,7 @@ class FederationFactory {
|
|
|
157
159
|
this.errors.push((0, errors_1.invalidImplementedTypeError)(data.name, invalidImplementationTypeStringByTypeName));
|
|
158
160
|
}
|
|
159
161
|
if (implementationErrorsMap.size) {
|
|
160
|
-
this.errors.push((0, errors_1.invalidInterfaceImplementationError)(data.node.name.value, (0,
|
|
162
|
+
this.errors.push((0, errors_1.invalidInterfaceImplementationError)(data.node.name.value, (0, utils_6.kindToTypeString)(data.kind), implementationErrorsMap));
|
|
161
163
|
}
|
|
162
164
|
return interfaces;
|
|
163
165
|
}
|
|
@@ -166,13 +168,13 @@ class FederationFactory {
|
|
|
166
168
|
if (!entityData) {
|
|
167
169
|
return;
|
|
168
170
|
}
|
|
169
|
-
const internalSubgraph = (0,
|
|
171
|
+
const internalSubgraph = (0, utils_6.getOrThrowError)(this.internalSubgraphBySubgraphName, this.currentSubgraphName, 'internalSubgraphBySubgraphName');
|
|
170
172
|
const parentDefinitionDataByTypeName = internalSubgraph.parentDefinitionDataByTypeName;
|
|
171
173
|
const objectData = parentDefinitionDataByTypeName.get(entityData.typeName);
|
|
172
174
|
if (!objectData || objectData.kind !== graphql_1.Kind.OBJECT_TYPE_DEFINITION) {
|
|
173
175
|
throw (0, errors_1.incompatibleParentKindFatalError)(entityData.typeName, graphql_1.Kind.OBJECT_TYPE_DEFINITION, objectData?.kind || graphql_1.Kind.NULL);
|
|
174
176
|
}
|
|
175
|
-
const configurationData = (0,
|
|
177
|
+
const configurationData = (0, utils_6.getOrThrowError)(internalSubgraph.configurationDataByTypeName, entityData.typeName, 'internalSubgraph.configurationDataByParentTypeName');
|
|
176
178
|
const implicitKeys = [];
|
|
177
179
|
const graphNode = this.internalGraph.nodeByNodeName.get(`${this.currentSubgraphName}.${entityData.typeName}`);
|
|
178
180
|
// Any errors in the field sets would be caught when evaluating the explicit entities, so they are ignored here
|
|
@@ -226,7 +228,7 @@ class FederationFactory {
|
|
|
226
228
|
if (!interfaceObjectData || interfaceObjectData.kind !== graphql_1.Kind.INTERFACE_TYPE_DEFINITION) {
|
|
227
229
|
throw (0, errors_1.incompatibleParentKindFatalError)(interfaceObjectTypeName, graphql_1.Kind.INTERFACE_TYPE_DEFINITION, interfaceObjectData?.kind || graphql_1.Kind.NULL);
|
|
228
230
|
}
|
|
229
|
-
const configurationData = (0,
|
|
231
|
+
const configurationData = (0, utils_6.getOrThrowError)(internalSubgraph.configurationDataByTypeName, entityData.typeName, 'internalSubgraph.configurationDataByParentTypeName');
|
|
230
232
|
const implicitKeys = [];
|
|
231
233
|
// Any errors in the field sets would be caught when evaluating the explicit entities, so they are ignored here
|
|
232
234
|
(0, utils_2.validateImplicitFieldSets)({
|
|
@@ -270,7 +272,7 @@ class FederationFactory {
|
|
|
270
272
|
if (paths.length < 1) {
|
|
271
273
|
continue;
|
|
272
274
|
}
|
|
273
|
-
const parentTagData = (0,
|
|
275
|
+
const parentTagData = (0, utils_6.getValueOrDefault)(this.parentTagDataByTypeName, paths[0], () => (0, utils_2.newParentTagData)(paths[0]));
|
|
274
276
|
switch (paths.length) {
|
|
275
277
|
// parent type
|
|
276
278
|
case 1:
|
|
@@ -280,15 +282,15 @@ class FederationFactory {
|
|
|
280
282
|
break;
|
|
281
283
|
// child type
|
|
282
284
|
case 2:
|
|
283
|
-
const childTagData = (0,
|
|
285
|
+
const childTagData = (0, utils_6.getValueOrDefault)(parentTagData.childTagDataByChildName, paths[1], () => (0, utils_2.newChildTagData)(paths[1]));
|
|
284
286
|
for (const tagName of tagNames) {
|
|
285
287
|
childTagData.tagNames.add(tagName);
|
|
286
288
|
}
|
|
287
289
|
break;
|
|
288
290
|
// field argument
|
|
289
291
|
case 3:
|
|
290
|
-
const fieldTagData = (0,
|
|
291
|
-
const argumentTagData = (0,
|
|
292
|
+
const fieldTagData = (0, utils_6.getValueOrDefault)(parentTagData.childTagDataByChildName, paths[1], () => (0, utils_2.newChildTagData)(paths[1]));
|
|
293
|
+
const argumentTagData = (0, utils_6.getValueOrDefault)(fieldTagData.tagNamesByArgumentName, paths[2], () => new Set());
|
|
292
294
|
for (const tagName of tagNames) {
|
|
293
295
|
argumentTagData.add(tagName);
|
|
294
296
|
}
|
|
@@ -320,7 +322,7 @@ class FederationFactory {
|
|
|
320
322
|
existingData.appearances += 1;
|
|
321
323
|
(0, utils_3.addMapEntries)(incomingData.configureDescriptionDataBySubgraphName, existingData.configureDescriptionDataBySubgraphName);
|
|
322
324
|
(0, utils_5.setLongestDescription)(existingData, incomingData);
|
|
323
|
-
(0,
|
|
325
|
+
(0, utils_6.addIterableValuesToSet)(incomingData.subgraphNames, existingData.subgraphNames);
|
|
324
326
|
}
|
|
325
327
|
// To facilitate the splitting of tag paths, field arguments do not use the renamedPath property for tagNamesByPath
|
|
326
328
|
upsertInputValueData(inputValueDataByValueName, incomingData, path) {
|
|
@@ -340,8 +342,8 @@ class FederationFactory {
|
|
|
340
342
|
}
|
|
341
343
|
(0, utils_3.addMapEntries)(incomingData.configureDescriptionDataBySubgraphName, existingData.configureDescriptionDataBySubgraphName);
|
|
342
344
|
(0, utils_5.setLongestDescription)(existingData, incomingData);
|
|
343
|
-
(0,
|
|
344
|
-
(0,
|
|
345
|
+
(0, utils_6.addIterableValuesToSet)(incomingData.requiredSubgraphNames, existingData.requiredSubgraphNames);
|
|
346
|
+
(0, utils_6.addIterableValuesToSet)(incomingData.subgraphNames, existingData.subgraphNames);
|
|
345
347
|
// TODO refactor type merging
|
|
346
348
|
const { typeErrors, typeNode } = (0, type_merging_1.getMostRestrictiveMergedTypeNode)(existingData.type, incomingData.type, existingData.originalPath, this.errors);
|
|
347
349
|
if (typeNode) {
|
|
@@ -376,7 +378,7 @@ class FederationFactory {
|
|
|
376
378
|
}
|
|
377
379
|
}
|
|
378
380
|
handleSubscriptionFilterDirective(incomingData, fieldPath, baseData) {
|
|
379
|
-
const subscriptionFilters = incomingData.directivesByDirectiveName.get(
|
|
381
|
+
const subscriptionFilters = incomingData.directivesByDirectiveName.get(string_constants_2.SUBSCRIPTION_FILTER);
|
|
380
382
|
if (subscriptionFilters) {
|
|
381
383
|
// There should only be a single entry in the set
|
|
382
384
|
const subgraphName = (0, utils_3.getSingleSetEntry)(incomingData.subgraphNames);
|
|
@@ -467,11 +469,11 @@ class FederationFactory {
|
|
|
467
469
|
if (!subgraphNamesByNamedTypeName) {
|
|
468
470
|
return;
|
|
469
471
|
}
|
|
470
|
-
(0,
|
|
472
|
+
(0, utils_6.addIterableValuesToSet)(incomingData.subgraphNames, (0, utils_6.getValueOrDefault)(subgraphNamesByNamedTypeName, incomingData.namedTypeName, () => new Set()));
|
|
471
473
|
}
|
|
472
474
|
upsertFieldData(fieldDataByFieldName, incomingData, isParentInaccessible) {
|
|
473
475
|
const fieldPath = `${incomingData.renamedParentTypeName}.${incomingData.name}`;
|
|
474
|
-
(0,
|
|
476
|
+
(0, utils_6.getValueOrDefault)(this.pathsByNamedTypeName, incomingData.namedTypeName, () => new Set()).add(fieldPath);
|
|
475
477
|
this.namedOutputTypeNames.add(incomingData.namedTypeName);
|
|
476
478
|
const existingData = fieldDataByFieldName.get(incomingData.name);
|
|
477
479
|
const baseData = existingData || incomingData;
|
|
@@ -501,7 +503,7 @@ class FederationFactory {
|
|
|
501
503
|
type: inputValueData.type,
|
|
502
504
|
};
|
|
503
505
|
const namedArgumentTypeName = (0, ast_1.getTypeNodeNamedTypeName)(inputValueData.type);
|
|
504
|
-
(0,
|
|
506
|
+
(0, utils_6.getValueOrDefault)(this.pathsByNamedTypeName, namedArgumentTypeName, () => new Set()).add(inputValueData.renamedPath);
|
|
505
507
|
this.namedInputValueTypeNames.add(namedArgumentTypeName);
|
|
506
508
|
(0, utils_5.extractPersistedDirectives)(inputValueData.persistedDirectivesData, inputValueData.directivesByDirectiveName, this.persistedDirectiveDefinitionByDirectiveName);
|
|
507
509
|
/* If either the parent or the field to which the field belongs are declared inaccessible, the nullability
|
|
@@ -521,11 +523,11 @@ class FederationFactory {
|
|
|
521
523
|
if (result.success) {
|
|
522
524
|
existingData.type = result.typeNode;
|
|
523
525
|
if (existingData.namedTypeName !== incomingData.namedTypeName) {
|
|
524
|
-
const subgraphNamesByNamedTypeName = (0,
|
|
526
|
+
const subgraphNamesByNamedTypeName = (0, utils_6.getValueOrDefault)(this.subgraphNamesByNamedTypeNameByFieldCoordinates, `${existingData.renamedParentTypeName}.${existingData.name}`, () => new Map());
|
|
525
527
|
/* Only propagate the subgraph names of the existing data if it has never been propagated before.
|
|
526
528
|
* This is to prevent the propagation of subgraph names where that named type is not returned.
|
|
527
529
|
*/
|
|
528
|
-
const existingSubgraphNames = (0,
|
|
530
|
+
const existingSubgraphNames = (0, utils_6.getValueOrDefault)(subgraphNamesByNamedTypeName, existingData.namedTypeName, () => new Set());
|
|
529
531
|
if (existingSubgraphNames.size < 1) {
|
|
530
532
|
// Add all subgraph names that are not the subgraph name in the incoming data
|
|
531
533
|
for (const subgraphName of existingData.subgraphNames) {
|
|
@@ -534,7 +536,7 @@ class FederationFactory {
|
|
|
534
536
|
}
|
|
535
537
|
}
|
|
536
538
|
}
|
|
537
|
-
(0,
|
|
539
|
+
(0, utils_6.addIterableValuesToSet)(incomingData.subgraphNames, (0, utils_6.getValueOrDefault)(subgraphNamesByNamedTypeName, incomingData.namedTypeName, () => new Set()));
|
|
538
540
|
}
|
|
539
541
|
else {
|
|
540
542
|
/* If the named types match but there has already been a disparity in the named type names returned by the
|
|
@@ -545,7 +547,7 @@ class FederationFactory {
|
|
|
545
547
|
}
|
|
546
548
|
for (const [argumentName, inputValueData] of incomingData.argumentDataByArgumentName) {
|
|
547
549
|
const namedArgumentTypeName = (0, ast_1.getTypeNodeNamedTypeName)(inputValueData.type);
|
|
548
|
-
(0,
|
|
550
|
+
(0, utils_6.getValueOrDefault)(this.pathsByNamedTypeName, namedArgumentTypeName, () => new Set()).add(inputValueData.renamedPath);
|
|
549
551
|
this.namedInputValueTypeNames.add(namedArgumentTypeName);
|
|
550
552
|
/* If either the parent or the field to which the field belongs are declared inaccessible, the nullability
|
|
551
553
|
** of the argument is not considered. However, if only the argument is declared inaccessible, it is an
|
|
@@ -558,7 +560,7 @@ class FederationFactory {
|
|
|
558
560
|
existingData.isInaccessible ||= incomingData.isInaccessible;
|
|
559
561
|
(0, utils_3.addMapEntries)(incomingData.isExternalBySubgraphName, existingData.isExternalBySubgraphName);
|
|
560
562
|
(0, utils_3.addMapEntries)(incomingData.isShareableBySubgraphName, existingData.isShareableBySubgraphName);
|
|
561
|
-
(0,
|
|
563
|
+
(0, utils_6.addIterableValuesToSet)(incomingData.subgraphNames, existingData.subgraphNames);
|
|
562
564
|
}
|
|
563
565
|
getClientSchemaUnionMembers(unionData) {
|
|
564
566
|
const members = [];
|
|
@@ -572,7 +574,7 @@ class FederationFactory {
|
|
|
572
574
|
recordTagNamesByPath(data, nodePath) {
|
|
573
575
|
const path = nodePath || data.name;
|
|
574
576
|
if (data.persistedDirectivesData.tags.size > 0) {
|
|
575
|
-
const tagNames = (0,
|
|
577
|
+
const tagNames = (0, utils_6.getValueOrDefault)(this.tagNamesByPath, path, () => new Set());
|
|
576
578
|
for (const tagName of data.persistedDirectivesData.tags.keys()) {
|
|
577
579
|
tagNames.add(tagName);
|
|
578
580
|
}
|
|
@@ -625,7 +627,7 @@ class FederationFactory {
|
|
|
625
627
|
type: inputValueData.type,
|
|
626
628
|
};
|
|
627
629
|
const namedInputFieldTypeName = (0, ast_1.getTypeNodeNamedTypeName)(inputValueData.type);
|
|
628
|
-
(0,
|
|
630
|
+
(0, utils_6.getValueOrDefault)(this.pathsByNamedTypeName, namedInputFieldTypeName, () => new Set()).add(inputValueData.renamedPath);
|
|
629
631
|
this.namedInputValueTypeNames.add(namedInputFieldTypeName);
|
|
630
632
|
(0, utils_5.extractPersistedDirectives)(inputValueData.persistedDirectivesData, inputValueData.directivesByDirectiveName, this.persistedDirectiveDefinitionByDirectiveName);
|
|
631
633
|
this.recordTagNamesByPath(inputValueData, `${incomingData.name}.${inputFieldName}`);
|
|
@@ -638,7 +640,7 @@ class FederationFactory {
|
|
|
638
640
|
// intentional fallthrough
|
|
639
641
|
case graphql_1.Kind.OBJECT_TYPE_DEFINITION:
|
|
640
642
|
if ((0, utils_5.isParentDataRootType)(incomingData)) {
|
|
641
|
-
incomingData.extensionType =
|
|
643
|
+
incomingData.extensionType = types_1.ExtensionType.NONE;
|
|
642
644
|
}
|
|
643
645
|
for (const [fieldName, fieldData] of incomingData.fieldDataByFieldName) {
|
|
644
646
|
fieldData.description = this.getInitialNodeDescription(fieldData);
|
|
@@ -651,7 +653,7 @@ class FederationFactory {
|
|
|
651
653
|
};
|
|
652
654
|
const fieldPath = `${fieldData.renamedParentTypeName}.${fieldName}`;
|
|
653
655
|
this.handleSubscriptionFilterDirective(fieldData, fieldPath);
|
|
654
|
-
(0,
|
|
656
|
+
(0, utils_6.getValueOrDefault)(this.pathsByNamedTypeName, fieldData.namedTypeName, () => new Set()).add(fieldPath);
|
|
655
657
|
this.namedOutputTypeNames.add(fieldData.namedTypeName);
|
|
656
658
|
(0, utils_5.extractPersistedDirectives)(fieldData.persistedDirectivesData, fieldData.directivesByDirectiveName, this.persistedDirectiveDefinitionByDirectiveName);
|
|
657
659
|
this.recordTagNamesByPath(fieldData, fieldPath);
|
|
@@ -668,7 +670,7 @@ class FederationFactory {
|
|
|
668
670
|
type: inputValueData.type,
|
|
669
671
|
};
|
|
670
672
|
const namedArgumentTypeName = (0, ast_1.getTypeNodeNamedTypeName)(inputValueData.type);
|
|
671
|
-
(0,
|
|
673
|
+
(0, utils_6.getValueOrDefault)(this.pathsByNamedTypeName, namedArgumentTypeName, () => new Set()).add(inputValueData.renamedPath);
|
|
672
674
|
this.namedInputValueTypeNames.add(namedArgumentTypeName);
|
|
673
675
|
(0, utils_5.extractPersistedDirectives)(inputValueData.persistedDirectivesData, inputValueData.directivesByDirectiveName, this.persistedDirectiveDefinitionByDirectiveName);
|
|
674
676
|
this.recordTagNamesByPath(inputValueData, `${fieldPath}.${argumentName}`);
|
|
@@ -689,7 +691,7 @@ class FederationFactory {
|
|
|
689
691
|
!entityInterfaceData.interfaceObjectSubgraphs.has(subgraphName) ||
|
|
690
692
|
existingData.kind !== graphql_1.Kind.INTERFACE_TYPE_DEFINITION ||
|
|
691
693
|
incomingData.kind !== graphql_1.Kind.OBJECT_TYPE_DEFINITION) {
|
|
692
|
-
this.errors.push((0, errors_1.incompatibleParentKindMergeError)(existingData.name, (0,
|
|
694
|
+
this.errors.push((0, errors_1.incompatibleParentKindMergeError)(existingData.name, (0, utils_6.kindToTypeString)(existingData.kind), (0, utils_6.kindToTypeString)(incomingData.kind)));
|
|
693
695
|
return;
|
|
694
696
|
}
|
|
695
697
|
}
|
|
@@ -699,7 +701,7 @@ class FederationFactory {
|
|
|
699
701
|
switch (existingData.kind) {
|
|
700
702
|
case graphql_1.Kind.ENUM_TYPE_DEFINITION:
|
|
701
703
|
existingData.appearances += 1;
|
|
702
|
-
(0,
|
|
704
|
+
(0, utils_6.addIterableValuesToSet)(incomingData.subgraphNames, existingData.subgraphNames);
|
|
703
705
|
for (const data of incomingData.enumValueDataByValueName.values()) {
|
|
704
706
|
this.upsertEnumValueData(existingData.enumValueDataByValueName, data, isParentInaccessible);
|
|
705
707
|
}
|
|
@@ -708,12 +710,12 @@ class FederationFactory {
|
|
|
708
710
|
if (isParentInaccessible && !existingData.isInaccessible) {
|
|
709
711
|
this.propagateInaccessibilityToExistingChildren(existingData);
|
|
710
712
|
}
|
|
711
|
-
(0,
|
|
713
|
+
(0, utils_6.addIterableValuesToSet)(incomingData.subgraphNames, existingData.subgraphNames);
|
|
712
714
|
for (const [inputFieldName, inputValueData] of incomingData
|
|
713
715
|
.inputValueDataByValueName) {
|
|
714
716
|
const inputFieldPath = `${incomingData.name}.${inputFieldName}`;
|
|
715
717
|
const namedInputFieldTypeName = (0, ast_1.getTypeNodeNamedTypeName)(inputValueData.type);
|
|
716
|
-
(0,
|
|
718
|
+
(0, utils_6.getValueOrDefault)(this.pathsByNamedTypeName, namedInputFieldTypeName, () => new Set()).add(inputFieldPath);
|
|
717
719
|
this.namedInputValueTypeNames.add(namedInputFieldTypeName);
|
|
718
720
|
this.upsertInputValueData(existingData.inputValueDataByValueName, inputValueData);
|
|
719
721
|
this.recordTagNamesByPath(inputValueData, inputFieldPath);
|
|
@@ -729,8 +731,8 @@ class FederationFactory {
|
|
|
729
731
|
this.propagateInaccessibilityToExistingChildren(existingData);
|
|
730
732
|
}
|
|
731
733
|
const compositeOutputData = incomingData;
|
|
732
|
-
(0,
|
|
733
|
-
(0,
|
|
734
|
+
(0, utils_6.addIterableValuesToSet)(compositeOutputData.implementedInterfaceTypeNames, existingData.implementedInterfaceTypeNames);
|
|
735
|
+
(0, utils_6.addIterableValuesToSet)(compositeOutputData.subgraphNames, existingData.subgraphNames);
|
|
734
736
|
for (const fieldData of compositeOutputData.fieldDataByFieldName.values()) {
|
|
735
737
|
this.upsertFieldData(existingData.fieldDataByFieldName, fieldData, isParentInaccessible || existingData.isInaccessible);
|
|
736
738
|
}
|
|
@@ -801,7 +803,7 @@ class FederationFactory {
|
|
|
801
803
|
}
|
|
802
804
|
(0, utils_5.setLongestDescription)(existingData, incomingData);
|
|
803
805
|
existingData.repeatable &&= incomingData.repeatable;
|
|
804
|
-
(0,
|
|
806
|
+
(0, utils_6.addIterableValuesToSet)(incomingData.subgraphNames, existingData.subgraphNames);
|
|
805
807
|
}
|
|
806
808
|
shouldUpdateFederatedFieldAbstractNamedType(abstractTypeName, objectTypeNames) {
|
|
807
809
|
if (!abstractTypeName) {
|
|
@@ -831,7 +833,7 @@ class FederationFactory {
|
|
|
831
833
|
handleDisparateFieldNamedTypes() {
|
|
832
834
|
for (const [fieldCoordinates, subgraphNamesByNamedTypeName] of this
|
|
833
835
|
.subgraphNamesByNamedTypeNameByFieldCoordinates) {
|
|
834
|
-
const coordinates = fieldCoordinates.split(
|
|
836
|
+
const coordinates = fieldCoordinates.split(string_constants_2.PERIOD);
|
|
835
837
|
if (coordinates.length !== 2) {
|
|
836
838
|
continue;
|
|
837
839
|
}
|
|
@@ -843,7 +845,7 @@ class FederationFactory {
|
|
|
843
845
|
// This error should never happen
|
|
844
846
|
if (compositeOutputData.kind !== graphql_1.Kind.INTERFACE_TYPE_DEFINITION &&
|
|
845
847
|
compositeOutputData.kind !== graphql_1.Kind.OBJECT_TYPE_DEFINITION) {
|
|
846
|
-
this.errors.push((0, errors_1.unexpectedNonCompositeOutputTypeError)(coordinates[0], (0,
|
|
848
|
+
this.errors.push((0, errors_1.unexpectedNonCompositeOutputTypeError)(coordinates[0], (0, utils_6.kindToTypeString)(compositeOutputData.kind)));
|
|
847
849
|
continue;
|
|
848
850
|
}
|
|
849
851
|
const fieldData = compositeOutputData.fieldDataByFieldName.get(coordinates[1]);
|
|
@@ -998,19 +1000,19 @@ class FederationFactory {
|
|
|
998
1000
|
handleEntityInterfaces() {
|
|
999
1001
|
for (const [entityInterfaceTypeName, entityInterfaceData] of this.entityInterfaceFederationDataByTypeName) {
|
|
1000
1002
|
(0, utils_3.subtractSourceSetFromTargetSet)(entityInterfaceData.interfaceFieldNames, entityInterfaceData.interfaceObjectFieldNames);
|
|
1001
|
-
const entityInterface = (0,
|
|
1003
|
+
const entityInterface = (0, utils_6.getOrThrowError)(this.parentDefinitionDataByTypeName, entityInterfaceTypeName, string_constants_2.PARENT_DEFINITION_DATA);
|
|
1002
1004
|
if (entityInterface.kind !== graphql_1.Kind.INTERFACE_TYPE_DEFINITION) {
|
|
1003
1005
|
// TODO error
|
|
1004
1006
|
continue;
|
|
1005
1007
|
}
|
|
1006
1008
|
for (const subgraphName of entityInterfaceData.interfaceObjectSubgraphs) {
|
|
1007
|
-
const internalSubgraph = (0,
|
|
1009
|
+
const internalSubgraph = (0, utils_6.getOrThrowError)(this.internalSubgraphBySubgraphName, subgraphName, 'internalSubgraphBySubgraphName');
|
|
1008
1010
|
const configurationDataMap = internalSubgraph.configurationDataByTypeName;
|
|
1009
1011
|
const concreteTypeNames = this.concreteTypeNamesByAbstractTypeName.get(entityInterfaceTypeName);
|
|
1010
1012
|
if (!concreteTypeNames) {
|
|
1011
1013
|
continue;
|
|
1012
1014
|
}
|
|
1013
|
-
const interfaceObjectConfiguration = (0,
|
|
1015
|
+
const interfaceObjectConfiguration = (0, utils_6.getOrThrowError)(configurationDataMap, entityInterfaceTypeName, 'configurationDataMap');
|
|
1014
1016
|
const keys = interfaceObjectConfiguration.keys;
|
|
1015
1017
|
if (!keys) {
|
|
1016
1018
|
// TODO no keys error
|
|
@@ -1027,19 +1029,19 @@ class FederationFactory {
|
|
|
1027
1029
|
continue;
|
|
1028
1030
|
}
|
|
1029
1031
|
if (authorizationData) {
|
|
1030
|
-
const concreteAuthorizationData = (0,
|
|
1032
|
+
const concreteAuthorizationData = (0, utils_6.getValueOrDefault)(this.authorizationDataByParentTypeName, concreteTypeName, () => (0, utils_3.newAuthorizationData)(concreteTypeName));
|
|
1031
1033
|
for (const fieldAuthorizationData of authorizationData.fieldAuthorizationDataByFieldName.values()) {
|
|
1032
1034
|
if (!(0, utils_3.upsertFieldAuthorizationData)(concreteAuthorizationData.fieldAuthorizationDataByFieldName, fieldAuthorizationData)) {
|
|
1033
1035
|
this.invalidOrScopesHostPaths.add(`${concreteTypeName}.${fieldAuthorizationData.fieldName}`);
|
|
1034
1036
|
}
|
|
1035
1037
|
}
|
|
1036
1038
|
}
|
|
1037
|
-
const concreteTypeData = (0,
|
|
1039
|
+
const concreteTypeData = (0, utils_6.getOrThrowError)(this.parentDefinitionDataByTypeName, concreteTypeName, string_constants_2.PARENT_DEFINITION_DATA);
|
|
1038
1040
|
if (concreteTypeData.kind !== graphql_1.Kind.OBJECT_TYPE_DEFINITION) {
|
|
1039
1041
|
continue;
|
|
1040
1042
|
}
|
|
1041
1043
|
// The subgraph locations of the interface object must be added to the concrete types that implement it
|
|
1042
|
-
const entityData = (0,
|
|
1044
|
+
const entityData = (0, utils_6.getOrThrowError)(this.entityDataByTypeName, concreteTypeName, 'entityDataByTypeName');
|
|
1043
1045
|
entityData.subgraphNames.add(subgraphName);
|
|
1044
1046
|
const configurationData = {
|
|
1045
1047
|
fieldNames,
|
|
@@ -1057,7 +1059,7 @@ class FederationFactory {
|
|
|
1057
1059
|
// TODO handle shareability
|
|
1058
1060
|
continue;
|
|
1059
1061
|
}
|
|
1060
|
-
const interfaceFieldData = (0,
|
|
1062
|
+
const interfaceFieldData = (0, utils_6.getOrThrowError)(entityInterface.fieldDataByFieldName, fieldName, `${entityInterfaceTypeName}.fieldDataByFieldName`);
|
|
1061
1063
|
concreteTypeData.fieldDataByFieldName.set(fieldName, { ...interfaceFieldData });
|
|
1062
1064
|
}
|
|
1063
1065
|
configurationDataMap.set(concreteTypeName, configurationData);
|
|
@@ -1171,17 +1173,17 @@ class FederationFactory {
|
|
|
1171
1173
|
else if ((0, utils_5.isTypeRequired)(inputValueData.type)) {
|
|
1172
1174
|
invalidRequiredArguments.push({
|
|
1173
1175
|
inputValueName: argumentName,
|
|
1174
|
-
missingSubgraphs: (0,
|
|
1176
|
+
missingSubgraphs: (0, utils_6.getEntriesNotInHashSet)(fieldData.subgraphNames, inputValueData.subgraphNames),
|
|
1175
1177
|
requiredSubgraphs: [...inputValueData.requiredSubgraphNames],
|
|
1176
1178
|
});
|
|
1177
1179
|
}
|
|
1178
1180
|
}
|
|
1179
1181
|
if (invalidRequiredArguments.length > 0) {
|
|
1180
|
-
this.errors.push((0, errors_1.invalidRequiredInputValueError)(
|
|
1182
|
+
this.errors.push((0, errors_1.invalidRequiredInputValueError)(string_constants_2.FIELD, fieldPath, invalidRequiredArguments));
|
|
1181
1183
|
}
|
|
1182
1184
|
else if (argumentNames.length > 0) {
|
|
1183
1185
|
// fieldConfiguration might already exist through subscriptionFilter
|
|
1184
|
-
(0,
|
|
1186
|
+
(0, utils_6.getValueOrDefault)(this.fieldConfigurationByFieldPath, fieldPath, () => ({
|
|
1185
1187
|
argumentNames,
|
|
1186
1188
|
fieldName: fieldData.name,
|
|
1187
1189
|
typeName: fieldData.renamedParentTypeName,
|
|
@@ -1199,8 +1201,8 @@ class FederationFactory {
|
|
|
1199
1201
|
}
|
|
1200
1202
|
pushParentDefinitionDataToDocumentDefinitions(interfaceImplementations) {
|
|
1201
1203
|
for (const [parentTypeName, parentDefinitionData] of this.parentDefinitionDataByTypeName) {
|
|
1202
|
-
if (parentDefinitionData.extensionType !==
|
|
1203
|
-
this.errors.push((0, errors_1.noBaseDefinitionForExtensionError)((0,
|
|
1204
|
+
if (parentDefinitionData.extensionType !== types_1.ExtensionType.NONE) {
|
|
1205
|
+
this.errors.push((0, errors_1.noBaseDefinitionForExtensionError)((0, utils_6.kindToTypeString)(parentDefinitionData.kind), parentTypeName));
|
|
1204
1206
|
}
|
|
1205
1207
|
switch (parentDefinitionData.kind) {
|
|
1206
1208
|
case graphql_1.Kind.ENUM_TYPE_DEFINITION:
|
|
@@ -1248,7 +1250,7 @@ class FederationFactory {
|
|
|
1248
1250
|
break;
|
|
1249
1251
|
}
|
|
1250
1252
|
if (clientEnumValueNodes.length < 1) {
|
|
1251
|
-
this.errors.push((0, errors_1.allChildDefinitionsAreInaccessibleError)((0,
|
|
1253
|
+
this.errors.push((0, errors_1.allChildDefinitionsAreInaccessibleError)((0, utils_6.kindToTypeString)(parentDefinitionData.kind), parentTypeName, string_constants_2.ENUM_VALUE));
|
|
1252
1254
|
break;
|
|
1253
1255
|
}
|
|
1254
1256
|
this.clientDefinitions.push({
|
|
@@ -1275,13 +1277,13 @@ class FederationFactory {
|
|
|
1275
1277
|
else if ((0, utils_5.isTypeRequired)(inputValueData.type)) {
|
|
1276
1278
|
invalidRequiredInputs.push({
|
|
1277
1279
|
inputValueName,
|
|
1278
|
-
missingSubgraphs: (0,
|
|
1280
|
+
missingSubgraphs: (0, utils_6.getEntriesNotInHashSet)(parentDefinitionData.subgraphNames, inputValueData.subgraphNames),
|
|
1279
1281
|
requiredSubgraphs: [...inputValueData.requiredSubgraphNames],
|
|
1280
1282
|
});
|
|
1281
1283
|
}
|
|
1282
1284
|
}
|
|
1283
1285
|
if (invalidRequiredInputs.length > 0) {
|
|
1284
|
-
this.errors.push((0, errors_1.invalidRequiredInputValueError)(
|
|
1286
|
+
this.errors.push((0, errors_1.invalidRequiredInputValueError)(string_constants_2.INPUT_OBJECT, parentTypeName, invalidRequiredInputs, false));
|
|
1285
1287
|
break;
|
|
1286
1288
|
}
|
|
1287
1289
|
parentDefinitionData.node.fields = inputValueNodes;
|
|
@@ -1291,7 +1293,7 @@ class FederationFactory {
|
|
|
1291
1293
|
break;
|
|
1292
1294
|
}
|
|
1293
1295
|
if (clientInputValueNodes.length < 1) {
|
|
1294
|
-
this.errors.push((0, errors_1.allChildDefinitionsAreInaccessibleError)((0,
|
|
1296
|
+
this.errors.push((0, errors_1.allChildDefinitionsAreInaccessibleError)((0, utils_6.kindToTypeString)(parentDefinitionData.kind), parentTypeName, 'input field'));
|
|
1295
1297
|
break;
|
|
1296
1298
|
}
|
|
1297
1299
|
this.clientDefinitions.push({
|
|
@@ -1349,8 +1351,8 @@ class FederationFactory {
|
|
|
1349
1351
|
}
|
|
1350
1352
|
if (clientSchemaFieldNodes.length < 1) {
|
|
1351
1353
|
const error = isQuery
|
|
1352
|
-
? errors_1.noQueryRootTypeError
|
|
1353
|
-
: (0, errors_1.allChildDefinitionsAreInaccessibleError)((0,
|
|
1354
|
+
? (0, errors_1.noQueryRootTypeError)(false)
|
|
1355
|
+
: (0, errors_1.allChildDefinitionsAreInaccessibleError)((0, utils_6.kindToTypeString)(parentDefinitionData.kind), parentTypeName, string_constants_2.FIELD);
|
|
1354
1356
|
this.errors.push(error);
|
|
1355
1357
|
break;
|
|
1356
1358
|
}
|
|
@@ -1385,7 +1387,7 @@ class FederationFactory {
|
|
|
1385
1387
|
}
|
|
1386
1388
|
const clientMembers = this.getClientSchemaUnionMembers(parentDefinitionData);
|
|
1387
1389
|
if (clientMembers.length < 1) {
|
|
1388
|
-
this.errors.push((0, errors_1.allChildDefinitionsAreInaccessibleError)(
|
|
1390
|
+
this.errors.push((0, errors_1.allChildDefinitionsAreInaccessibleError)(string_constants_2.UNION, parentTypeName, 'union member type'));
|
|
1389
1391
|
break;
|
|
1390
1392
|
}
|
|
1391
1393
|
this.clientDefinitions.push({
|
|
@@ -1453,8 +1455,8 @@ class FederationFactory {
|
|
|
1453
1455
|
if (!path) {
|
|
1454
1456
|
return false;
|
|
1455
1457
|
}
|
|
1456
|
-
const coordinates = path.split(
|
|
1457
|
-
const segments = coordinates.split(
|
|
1458
|
+
const coordinates = path.split(string_constants_2.LEFT_PARENTHESIS)[0];
|
|
1459
|
+
const segments = coordinates.split(string_constants_2.PERIOD);
|
|
1458
1460
|
let segment = segments[0];
|
|
1459
1461
|
for (let i = 0; i < segments.length; i++) {
|
|
1460
1462
|
if (this.inaccessiblePaths.has(segment)) {
|
|
@@ -1479,13 +1481,13 @@ class FederationFactory {
|
|
|
1479
1481
|
}
|
|
1480
1482
|
}
|
|
1481
1483
|
if (invalidPaths.length > 0) {
|
|
1482
|
-
this.errors.push((0, errors_1.invalidReferencesOfInaccessibleTypeError)((0,
|
|
1484
|
+
this.errors.push((0, errors_1.invalidReferencesOfInaccessibleTypeError)((0, utils_6.kindToTypeString)(data.kind), data.name, invalidPaths));
|
|
1483
1485
|
}
|
|
1484
1486
|
}
|
|
1485
1487
|
validateQueryRootType() {
|
|
1486
|
-
const query = this.parentDefinitionDataByTypeName.get(
|
|
1488
|
+
const query = this.parentDefinitionDataByTypeName.get(string_constants_2.QUERY);
|
|
1487
1489
|
if (!query || query.kind !== graphql_1.Kind.OBJECT_TYPE_DEFINITION || query.fieldDataByFieldName.size < 1) {
|
|
1488
|
-
this.errors.push(errors_1.noQueryRootTypeError);
|
|
1490
|
+
this.errors.push((0, errors_1.noQueryRootTypeError)());
|
|
1489
1491
|
return;
|
|
1490
1492
|
}
|
|
1491
1493
|
for (const fieldData of query.fieldDataByFieldName.values()) {
|
|
@@ -1493,10 +1495,10 @@ class FederationFactory {
|
|
|
1493
1495
|
return;
|
|
1494
1496
|
}
|
|
1495
1497
|
}
|
|
1496
|
-
this.errors.push(errors_1.noQueryRootTypeError);
|
|
1498
|
+
this.errors.push((0, errors_1.noQueryRootTypeError)());
|
|
1497
1499
|
}
|
|
1498
1500
|
validateSubscriptionFieldConditionFieldPath(conditionFieldPath, objectData, inputFieldPath, directiveSubgraphName, fieldErrorMessages) {
|
|
1499
|
-
const paths = conditionFieldPath.split(
|
|
1501
|
+
const paths = conditionFieldPath.split(string_constants_2.PERIOD);
|
|
1500
1502
|
if (paths.length < 1) {
|
|
1501
1503
|
fieldErrorMessages.push((0, errors_1.invalidSubscriptionFieldConditionFieldPathErrorMessage)(inputFieldPath, conditionFieldPath));
|
|
1502
1504
|
return [];
|
|
@@ -1532,10 +1534,10 @@ class FederationFactory {
|
|
|
1532
1534
|
lastData = { kind: graphql_1.Kind.SCALAR_TYPE_DEFINITION, name: fieldData.namedTypeName };
|
|
1533
1535
|
continue;
|
|
1534
1536
|
}
|
|
1535
|
-
lastData = (0,
|
|
1537
|
+
lastData = (0, utils_6.getOrThrowError)(this.parentDefinitionDataByTypeName, fieldData.namedTypeName, string_constants_2.PARENT_DEFINITION_DATA);
|
|
1536
1538
|
}
|
|
1537
1539
|
if (!(0, utils_5.isLeafKind)(lastData.kind)) {
|
|
1538
|
-
fieldErrorMessages.push((0, errors_1.nonLeafSubscriptionFieldConditionFieldPathFinalFieldErrorMessage)(inputFieldPath, conditionFieldPath, paths[paths.length - 1], (0,
|
|
1540
|
+
fieldErrorMessages.push((0, errors_1.nonLeafSubscriptionFieldConditionFieldPathFinalFieldErrorMessage)(inputFieldPath, conditionFieldPath, paths[paths.length - 1], (0, utils_6.kindToTypeString)(lastData.kind), lastData.name));
|
|
1539
1541
|
return [];
|
|
1540
1542
|
}
|
|
1541
1543
|
return paths;
|
|
@@ -1547,7 +1549,7 @@ class FederationFactory {
|
|
|
1547
1549
|
return false;
|
|
1548
1550
|
}
|
|
1549
1551
|
let hasErrors = false;
|
|
1550
|
-
const validFieldNames = new Set([
|
|
1552
|
+
const validFieldNames = new Set([string_constants_2.FIELD_PATH, string_constants_2.VALUES]);
|
|
1551
1553
|
const duplicatedFieldNames = new Set();
|
|
1552
1554
|
const invalidFieldNames = new Set();
|
|
1553
1555
|
const fieldErrorMessages = [];
|
|
@@ -1555,17 +1557,17 @@ class FederationFactory {
|
|
|
1555
1557
|
const inputFieldName = objectFieldNode.name.value;
|
|
1556
1558
|
const inputFieldPath = inputPath + `.${inputFieldName}`;
|
|
1557
1559
|
switch (inputFieldName) {
|
|
1558
|
-
case
|
|
1559
|
-
if (validFieldNames.has(
|
|
1560
|
-
validFieldNames.delete(
|
|
1560
|
+
case string_constants_2.FIELD_PATH: {
|
|
1561
|
+
if (validFieldNames.has(string_constants_2.FIELD_PATH)) {
|
|
1562
|
+
validFieldNames.delete(string_constants_2.FIELD_PATH);
|
|
1561
1563
|
}
|
|
1562
1564
|
else {
|
|
1563
1565
|
hasErrors = true;
|
|
1564
|
-
duplicatedFieldNames.add(
|
|
1566
|
+
duplicatedFieldNames.add(string_constants_2.FIELD_PATH);
|
|
1565
1567
|
break;
|
|
1566
1568
|
}
|
|
1567
1569
|
if (objectFieldNode.value.kind !== graphql_1.Kind.STRING) {
|
|
1568
|
-
fieldErrorMessages.push((0, errors_1.invalidInputFieldTypeErrorMessage)(inputFieldPath,
|
|
1570
|
+
fieldErrorMessages.push((0, errors_1.invalidInputFieldTypeErrorMessage)(inputFieldPath, string_constants_2.STRING, (0, utils_6.kindToTypeString)(objectFieldNode.value.kind)));
|
|
1569
1571
|
hasErrors = true;
|
|
1570
1572
|
break;
|
|
1571
1573
|
}
|
|
@@ -1577,18 +1579,18 @@ class FederationFactory {
|
|
|
1577
1579
|
condition.fieldPath = fieldPath;
|
|
1578
1580
|
break;
|
|
1579
1581
|
}
|
|
1580
|
-
case
|
|
1581
|
-
if (validFieldNames.has(
|
|
1582
|
-
validFieldNames.delete(
|
|
1582
|
+
case string_constants_2.VALUES: {
|
|
1583
|
+
if (validFieldNames.has(string_constants_2.VALUES)) {
|
|
1584
|
+
validFieldNames.delete(string_constants_2.VALUES);
|
|
1583
1585
|
}
|
|
1584
1586
|
else {
|
|
1585
1587
|
hasErrors = true;
|
|
1586
|
-
duplicatedFieldNames.add(
|
|
1588
|
+
duplicatedFieldNames.add(string_constants_2.VALUES);
|
|
1587
1589
|
break;
|
|
1588
1590
|
}
|
|
1589
1591
|
const objectFieldValueKind = objectFieldNode.value.kind;
|
|
1590
1592
|
if (objectFieldValueKind == graphql_1.Kind.NULL || objectFieldValueKind == graphql_1.Kind.OBJECT) {
|
|
1591
|
-
fieldErrorMessages.push((0, errors_1.invalidInputFieldTypeErrorMessage)(inputFieldPath,
|
|
1593
|
+
fieldErrorMessages.push((0, errors_1.invalidInputFieldTypeErrorMessage)(inputFieldPath, string_constants_2.LIST, (0, utils_6.kindToTypeString)(objectFieldNode.value.kind)));
|
|
1592
1594
|
hasErrors = true;
|
|
1593
1595
|
break;
|
|
1594
1596
|
}
|
|
@@ -1654,34 +1656,34 @@ class FederationFactory {
|
|
|
1654
1656
|
switch (objectFieldNode.value.kind) {
|
|
1655
1657
|
case graphql_1.Kind.OBJECT: {
|
|
1656
1658
|
switch (fieldName) {
|
|
1657
|
-
case
|
|
1659
|
+
case string_constants_2.IN_UPPER: {
|
|
1658
1660
|
configuration.in = { fieldPath: [], values: [] };
|
|
1659
1661
|
return this.validateSubscriptionFieldCondition(objectFieldNode.value, configuration.in, objectData, depth, inputPath + `.IN`, directiveSubgraphName, errorMessages);
|
|
1660
1662
|
}
|
|
1661
|
-
case
|
|
1663
|
+
case string_constants_2.NOT_UPPER: {
|
|
1662
1664
|
configuration.not = {};
|
|
1663
1665
|
return this.validateSubscriptionFilterCondition(objectFieldNode.value, configuration.not, objectData, depth, inputPath + `.NOT`, directiveSubgraphName, errorMessages);
|
|
1664
1666
|
}
|
|
1665
1667
|
default:
|
|
1666
1668
|
// The field is guaranteed to be an AND or an OR
|
|
1667
|
-
errorMessages.push((0, errors_1.subscriptionFilterConditionInvalidInputFieldTypeErrorMessage)(inputFieldPath,
|
|
1669
|
+
errorMessages.push((0, errors_1.subscriptionFilterConditionInvalidInputFieldTypeErrorMessage)(inputFieldPath, string_constants_2.LIST, string_constants_2.OBJECT));
|
|
1668
1670
|
return false;
|
|
1669
1671
|
}
|
|
1670
1672
|
}
|
|
1671
1673
|
case graphql_1.Kind.LIST: {
|
|
1672
1674
|
const listConfigurations = [];
|
|
1673
1675
|
switch (fieldName) {
|
|
1674
|
-
case
|
|
1676
|
+
case string_constants_2.AND_UPPER: {
|
|
1675
1677
|
configuration.and = listConfigurations;
|
|
1676
1678
|
break;
|
|
1677
1679
|
}
|
|
1678
|
-
case
|
|
1680
|
+
case string_constants_2.OR_UPPER: {
|
|
1679
1681
|
configuration.or = listConfigurations;
|
|
1680
1682
|
break;
|
|
1681
1683
|
}
|
|
1682
1684
|
default:
|
|
1683
1685
|
// The field is guaranteed to be an IN or a NOT
|
|
1684
|
-
errorMessages.push((0, errors_1.subscriptionFilterConditionInvalidInputFieldTypeErrorMessage)(inputFieldPath,
|
|
1686
|
+
errorMessages.push((0, errors_1.subscriptionFilterConditionInvalidInputFieldTypeErrorMessage)(inputFieldPath, string_constants_2.OBJECT, string_constants_2.LIST));
|
|
1685
1687
|
return false;
|
|
1686
1688
|
}
|
|
1687
1689
|
const listLength = objectFieldNode.value.values.length;
|
|
@@ -1711,8 +1713,8 @@ class FederationFactory {
|
|
|
1711
1713
|
return isValid;
|
|
1712
1714
|
}
|
|
1713
1715
|
default: {
|
|
1714
|
-
const expectedTypeString = string_constants_1.SUBSCRIPTION_FILTER_LIST_INPUT_NAMES.has(fieldName) ?
|
|
1715
|
-
errorMessages.push((0, errors_1.subscriptionFilterConditionInvalidInputFieldTypeErrorMessage)(inputFieldPath, expectedTypeString, (0,
|
|
1716
|
+
const expectedTypeString = string_constants_1.SUBSCRIPTION_FILTER_LIST_INPUT_NAMES.has(fieldName) ? string_constants_2.LIST : string_constants_2.OBJECT;
|
|
1717
|
+
errorMessages.push((0, errors_1.subscriptionFilterConditionInvalidInputFieldTypeErrorMessage)(inputFieldPath, expectedTypeString, (0, utils_6.kindToTypeString)(objectFieldNode.value.kind)));
|
|
1716
1718
|
return false;
|
|
1717
1719
|
}
|
|
1718
1720
|
}
|
|
@@ -1725,18 +1727,18 @@ class FederationFactory {
|
|
|
1725
1727
|
const argumentNode = directiveNode.arguments[0];
|
|
1726
1728
|
if (argumentNode.value.kind !== graphql_1.Kind.OBJECT) {
|
|
1727
1729
|
this.errors.push((0, errors_1.invalidSubscriptionFilterDirectiveError)(fieldPath, [
|
|
1728
|
-
(0, errors_1.subscriptionFilterConditionInvalidInputFieldTypeErrorMessage)(
|
|
1730
|
+
(0, errors_1.subscriptionFilterConditionInvalidInputFieldTypeErrorMessage)(string_constants_2.CONDITION, string_constants_2.OBJECT, (0, utils_6.kindToTypeString)(argumentNode.value.kind)),
|
|
1729
1731
|
]));
|
|
1730
1732
|
return;
|
|
1731
1733
|
}
|
|
1732
1734
|
const condition = {};
|
|
1733
1735
|
const errorMessages = [];
|
|
1734
|
-
if (!this.validateSubscriptionFilterCondition(argumentNode.value, condition, objectData, 0,
|
|
1736
|
+
if (!this.validateSubscriptionFilterCondition(argumentNode.value, condition, objectData, 0, string_constants_2.CONDITION, directiveSubgraphName, errorMessages)) {
|
|
1735
1737
|
this.errors.push((0, errors_1.invalidSubscriptionFilterDirectiveError)(fieldPath, errorMessages));
|
|
1736
1738
|
this.isMaxDepth = false;
|
|
1737
1739
|
return;
|
|
1738
1740
|
}
|
|
1739
|
-
(0,
|
|
1741
|
+
(0, utils_6.getValueOrDefault)(this.fieldConfigurationByFieldPath, fieldPath, () => ({
|
|
1740
1742
|
argumentNames: [],
|
|
1741
1743
|
fieldName,
|
|
1742
1744
|
typeName: parentTypeName,
|
|
@@ -1784,7 +1786,7 @@ class FederationFactory {
|
|
|
1784
1786
|
this.validateQueryRootType();
|
|
1785
1787
|
// Return any composition errors before checking whether all fields are resolvable
|
|
1786
1788
|
if (this.errors.length > 0) {
|
|
1787
|
-
return { errors: this.errors, warnings: this.warnings };
|
|
1789
|
+
return { errors: this.errors, success: false, warnings: this.warnings };
|
|
1788
1790
|
}
|
|
1789
1791
|
/* Resolvability evaluations are not necessary for contracts because the source graph resolvability evaluations
|
|
1790
1792
|
* must have already completed without error.
|
|
@@ -1793,11 +1795,11 @@ class FederationFactory {
|
|
|
1793
1795
|
if (this.internalSubgraphBySubgraphName.size > 1) {
|
|
1794
1796
|
const resolvabilityErrors = this.internalGraph.validate();
|
|
1795
1797
|
if (resolvabilityErrors.length > 0) {
|
|
1796
|
-
return { errors: resolvabilityErrors, warnings: this.warnings };
|
|
1798
|
+
return { errors: resolvabilityErrors, success: false, warnings: this.warnings };
|
|
1797
1799
|
}
|
|
1798
1800
|
}
|
|
1799
1801
|
if (this.errors.length > 0) {
|
|
1800
|
-
return { errors: this.errors, warnings: this.warnings };
|
|
1802
|
+
return { errors: this.errors, success: false, warnings: this.warnings };
|
|
1801
1803
|
}
|
|
1802
1804
|
const newRouterAST = {
|
|
1803
1805
|
kind: graphql_1.Kind.DOCUMENT,
|
|
@@ -1818,16 +1820,15 @@ class FederationFactory {
|
|
|
1818
1820
|
(0, utils_3.upsertAuthorizationConfiguration)(this.fieldConfigurationByFieldPath, authorizationData);
|
|
1819
1821
|
}
|
|
1820
1822
|
return {
|
|
1821
|
-
|
|
1822
|
-
|
|
1823
|
-
|
|
1824
|
-
|
|
1825
|
-
|
|
1826
|
-
|
|
1827
|
-
|
|
1828
|
-
...this.getClientSchemaObjectBoolean(),
|
|
1829
|
-
},
|
|
1823
|
+
fieldConfigurations: Array.from(this.fieldConfigurationByFieldPath.values()),
|
|
1824
|
+
subgraphConfigBySubgraphName,
|
|
1825
|
+
federatedGraphAST: newRouterAST,
|
|
1826
|
+
federatedGraphSchema: (0, graphql_1.buildASTSchema)(newRouterAST, { assumeValid: true, assumeValidSDL: true }),
|
|
1827
|
+
federatedGraphClientSchema: newClientSchema,
|
|
1828
|
+
parentDefinitionDataByTypeName: this.parentDefinitionDataByTypeName,
|
|
1829
|
+
success: true,
|
|
1830
1830
|
warnings: this.warnings,
|
|
1831
|
+
...this.getClientSchemaObjectBoolean(),
|
|
1831
1832
|
};
|
|
1832
1833
|
}
|
|
1833
1834
|
getClientSchemaObjectBoolean() {
|
|
@@ -1841,22 +1842,22 @@ class FederationFactory {
|
|
|
1841
1842
|
handleChildTagExclusions(parentDefinitionData, children, childTagDataByChildName, tagNames) {
|
|
1842
1843
|
let accessibleChildren = children.size;
|
|
1843
1844
|
for (const [childName, childTagData] of childTagDataByChildName) {
|
|
1844
|
-
const childData = (0,
|
|
1845
|
+
const childData = (0, utils_6.getOrThrowError)(children, childName, `${parentDefinitionData.name}.childDataByChildName`);
|
|
1845
1846
|
if ((0, utils_5.isNodeDataInaccessible)(childData)) {
|
|
1846
1847
|
accessibleChildren -= 1;
|
|
1847
1848
|
continue;
|
|
1848
1849
|
}
|
|
1849
|
-
if (
|
|
1850
|
-
(0,
|
|
1851
|
-
(0,
|
|
1850
|
+
if (!tagNames.isDisjointFrom(childTagData.tagNames)) {
|
|
1851
|
+
(0, utils_6.getValueOrDefault)(childData.persistedDirectivesData.directives, string_constants_2.INACCESSIBLE, () => [
|
|
1852
|
+
(0, utils_6.generateSimpleDirective)(string_constants_2.INACCESSIBLE),
|
|
1852
1853
|
]);
|
|
1853
1854
|
this.inaccessiblePaths.add(`${parentDefinitionData.name}.${childName}`);
|
|
1854
1855
|
accessibleChildren -= 1;
|
|
1855
1856
|
}
|
|
1856
1857
|
}
|
|
1857
1858
|
if (accessibleChildren < 1) {
|
|
1858
|
-
parentDefinitionData.persistedDirectivesData.directives.set(
|
|
1859
|
-
(0,
|
|
1859
|
+
parentDefinitionData.persistedDirectivesData.directives.set(string_constants_2.INACCESSIBLE, [
|
|
1860
|
+
(0, utils_6.generateSimpleDirective)(string_constants_2.INACCESSIBLE),
|
|
1860
1861
|
]);
|
|
1861
1862
|
this.inaccessiblePaths.add(parentDefinitionData.name);
|
|
1862
1863
|
}
|
|
@@ -1869,17 +1870,17 @@ class FederationFactory {
|
|
|
1869
1870
|
continue;
|
|
1870
1871
|
}
|
|
1871
1872
|
const childTagData = childTagDataByChildName.get(childName);
|
|
1872
|
-
if (!childTagData ||
|
|
1873
|
-
(0,
|
|
1874
|
-
(0,
|
|
1873
|
+
if (!childTagData || tagNames.isDisjointFrom(childTagData.tagNames)) {
|
|
1874
|
+
(0, utils_6.getValueOrDefault)(childData.persistedDirectivesData.directives, string_constants_2.INACCESSIBLE, () => [
|
|
1875
|
+
(0, utils_6.generateSimpleDirective)(string_constants_2.INACCESSIBLE),
|
|
1875
1876
|
]);
|
|
1876
1877
|
this.inaccessiblePaths.add(`${parentDefinitionData.name}.${childName}`);
|
|
1877
1878
|
accessibleChildren -= 1;
|
|
1878
1879
|
}
|
|
1879
1880
|
}
|
|
1880
1881
|
if (accessibleChildren < 1) {
|
|
1881
|
-
parentDefinitionData.persistedDirectivesData.directives.set(
|
|
1882
|
-
(0,
|
|
1882
|
+
parentDefinitionData.persistedDirectivesData.directives.set(string_constants_2.INACCESSIBLE, [
|
|
1883
|
+
(0, utils_6.generateSimpleDirective)(string_constants_2.INACCESSIBLE),
|
|
1883
1884
|
]);
|
|
1884
1885
|
this.inaccessiblePaths.add(parentDefinitionData.name);
|
|
1885
1886
|
}
|
|
@@ -1892,13 +1893,13 @@ class FederationFactory {
|
|
|
1892
1893
|
}
|
|
1893
1894
|
if (contractTagOptions.tagNamesToExclude.size > 0) {
|
|
1894
1895
|
for (const [parentTypeName, parentTagData] of this.parentTagDataByTypeName) {
|
|
1895
|
-
const parentDefinitionData = (0,
|
|
1896
|
+
const parentDefinitionData = (0, utils_6.getOrThrowError)(this.parentDefinitionDataByTypeName, parentTypeName, string_constants_2.PARENT_DEFINITION_DATA);
|
|
1896
1897
|
if ((0, utils_5.isNodeDataInaccessible)(parentDefinitionData)) {
|
|
1897
1898
|
continue;
|
|
1898
1899
|
}
|
|
1899
|
-
if (
|
|
1900
|
-
parentDefinitionData.persistedDirectivesData.directives.set(
|
|
1901
|
-
(0,
|
|
1900
|
+
if (!contractTagOptions.tagNamesToExclude.isDisjointFrom(parentTagData.tagNames)) {
|
|
1901
|
+
parentDefinitionData.persistedDirectivesData.directives.set(string_constants_2.INACCESSIBLE, [
|
|
1902
|
+
(0, utils_6.generateSimpleDirective)(string_constants_2.INACCESSIBLE),
|
|
1902
1903
|
]);
|
|
1903
1904
|
this.inaccessiblePaths.add(parentTypeName);
|
|
1904
1905
|
// If the parent is inaccessible, there is no need to assess further
|
|
@@ -1921,35 +1922,35 @@ class FederationFactory {
|
|
|
1921
1922
|
default:
|
|
1922
1923
|
let accessibleFields = parentDefinitionData.fieldDataByFieldName.size;
|
|
1923
1924
|
for (const [fieldName, childTagData] of parentTagData.childTagDataByChildName) {
|
|
1924
|
-
const fieldData = (0,
|
|
1925
|
+
const fieldData = (0, utils_6.getOrThrowError)(parentDefinitionData.fieldDataByFieldName, fieldName, `${parentTypeName}.fieldDataByFieldName`);
|
|
1925
1926
|
if ((0, utils_5.isNodeDataInaccessible)(fieldData)) {
|
|
1926
1927
|
accessibleFields -= 1;
|
|
1927
1928
|
continue;
|
|
1928
1929
|
}
|
|
1929
|
-
if (
|
|
1930
|
-
(0,
|
|
1931
|
-
(0,
|
|
1930
|
+
if (!contractTagOptions.tagNamesToExclude.isDisjointFrom(childTagData.tagNames)) {
|
|
1931
|
+
(0, utils_6.getValueOrDefault)(fieldData.persistedDirectivesData.directives, string_constants_2.INACCESSIBLE, () => [
|
|
1932
|
+
(0, utils_6.generateSimpleDirective)(string_constants_2.INACCESSIBLE),
|
|
1932
1933
|
]);
|
|
1933
1934
|
this.inaccessiblePaths.add(`${parentTypeName}.${fieldName}`);
|
|
1934
1935
|
accessibleFields -= 1;
|
|
1935
1936
|
continue;
|
|
1936
1937
|
}
|
|
1937
1938
|
for (const [argumentName, tagNames] of childTagData.tagNamesByArgumentName) {
|
|
1938
|
-
const inputValueData = (0,
|
|
1939
|
+
const inputValueData = (0, utils_6.getOrThrowError)(fieldData.argumentDataByArgumentName, argumentName, `${fieldName}.argumentDataByArgumentName`);
|
|
1939
1940
|
if ((0, utils_5.isNodeDataInaccessible)(inputValueData)) {
|
|
1940
1941
|
continue;
|
|
1941
1942
|
}
|
|
1942
|
-
if (
|
|
1943
|
-
(0,
|
|
1944
|
-
(0,
|
|
1943
|
+
if (!tagNames.isDisjointFrom(tagNames)) {
|
|
1944
|
+
(0, utils_6.getValueOrDefault)(inputValueData.persistedDirectivesData.directives, string_constants_2.INACCESSIBLE, () => [
|
|
1945
|
+
(0, utils_6.generateSimpleDirective)(string_constants_2.INACCESSIBLE),
|
|
1945
1946
|
]);
|
|
1946
1947
|
this.inaccessiblePaths.add(inputValueData.renamedPath);
|
|
1947
1948
|
}
|
|
1948
1949
|
}
|
|
1949
1950
|
}
|
|
1950
1951
|
if (accessibleFields < 1) {
|
|
1951
|
-
parentDefinitionData.persistedDirectivesData.directives.set(
|
|
1952
|
-
(0,
|
|
1952
|
+
parentDefinitionData.persistedDirectivesData.directives.set(string_constants_2.INACCESSIBLE, [
|
|
1953
|
+
(0, utils_6.generateSimpleDirective)(string_constants_2.INACCESSIBLE),
|
|
1953
1954
|
]);
|
|
1954
1955
|
this.inaccessiblePaths.add(parentTypeName);
|
|
1955
1956
|
}
|
|
@@ -1963,19 +1964,19 @@ class FederationFactory {
|
|
|
1963
1964
|
}
|
|
1964
1965
|
const parentTagData = this.parentTagDataByTypeName.get(parentTypeName);
|
|
1965
1966
|
if (!parentTagData) {
|
|
1966
|
-
parentDefinitionData.persistedDirectivesData.directives.set(
|
|
1967
|
-
(0,
|
|
1967
|
+
parentDefinitionData.persistedDirectivesData.directives.set(string_constants_2.INACCESSIBLE, [
|
|
1968
|
+
(0, utils_6.generateSimpleDirective)(string_constants_2.INACCESSIBLE),
|
|
1968
1969
|
]);
|
|
1969
1970
|
this.inaccessiblePaths.add(parentTypeName);
|
|
1970
1971
|
// If the parent is inaccessible, there is no need to assess further
|
|
1971
1972
|
continue;
|
|
1972
1973
|
}
|
|
1973
|
-
if (
|
|
1974
|
+
if (!contractTagOptions.tagNamesToInclude.isDisjointFrom(parentTagData.tagNames)) {
|
|
1974
1975
|
continue;
|
|
1975
1976
|
}
|
|
1976
1977
|
if (parentTagData.childTagDataByChildName.size < 1) {
|
|
1977
|
-
parentDefinitionData.persistedDirectivesData.directives.set(
|
|
1978
|
-
(0,
|
|
1978
|
+
parentDefinitionData.persistedDirectivesData.directives.set(string_constants_2.INACCESSIBLE, [
|
|
1979
|
+
(0, utils_6.generateSimpleDirective)(string_constants_2.INACCESSIBLE),
|
|
1979
1980
|
]);
|
|
1980
1981
|
this.inaccessiblePaths.add(parentTypeName);
|
|
1981
1982
|
// If the parent is inaccessible, there is no need to assess further
|
|
@@ -2000,17 +2001,17 @@ class FederationFactory {
|
|
|
2000
2001
|
continue;
|
|
2001
2002
|
}
|
|
2002
2003
|
const childTagData = parentTagData.childTagDataByChildName.get(fieldName);
|
|
2003
|
-
if (!childTagData ||
|
|
2004
|
-
(0,
|
|
2005
|
-
(0,
|
|
2004
|
+
if (!childTagData || contractTagOptions.tagNamesToInclude.isDisjointFrom(childTagData.tagNames)) {
|
|
2005
|
+
(0, utils_6.getValueOrDefault)(fieldData.persistedDirectivesData.directives, string_constants_2.INACCESSIBLE, () => [
|
|
2006
|
+
(0, utils_6.generateSimpleDirective)(string_constants_2.INACCESSIBLE),
|
|
2006
2007
|
]);
|
|
2007
2008
|
this.inaccessiblePaths.add(`${parentTypeName}.${fieldName}`);
|
|
2008
2009
|
accessibleFields -= 1;
|
|
2009
2010
|
}
|
|
2010
2011
|
}
|
|
2011
2012
|
if (accessibleFields < 1) {
|
|
2012
|
-
parentDefinitionData.persistedDirectivesData.directives.set(
|
|
2013
|
-
(0,
|
|
2013
|
+
parentDefinitionData.persistedDirectivesData.directives.set(string_constants_2.INACCESSIBLE, [
|
|
2014
|
+
(0, utils_6.generateSimpleDirective)(string_constants_2.INACCESSIBLE),
|
|
2014
2015
|
]);
|
|
2015
2016
|
this.inaccessiblePaths.add(parentTypeName);
|
|
2016
2017
|
}
|
|
@@ -2028,7 +2029,7 @@ class FederationFactory {
|
|
|
2028
2029
|
this.validateInterfaceImplementationsAndPushToDocumentDefinitions(interfaceImplementations);
|
|
2029
2030
|
this.validateQueryRootType();
|
|
2030
2031
|
if (this.errors.length > 0) {
|
|
2031
|
-
return { errors: this.errors, warnings: this.warnings };
|
|
2032
|
+
return { errors: this.errors, success: false, warnings: this.warnings };
|
|
2032
2033
|
}
|
|
2033
2034
|
const newRouterAST = {
|
|
2034
2035
|
kind: graphql_1.Kind.DOCUMENT,
|
|
@@ -2049,16 +2050,15 @@ class FederationFactory {
|
|
|
2049
2050
|
(0, utils_3.upsertAuthorizationConfiguration)(this.fieldConfigurationByFieldPath, authorizationData);
|
|
2050
2051
|
}
|
|
2051
2052
|
return {
|
|
2052
|
-
|
|
2053
|
-
|
|
2054
|
-
|
|
2055
|
-
|
|
2056
|
-
|
|
2057
|
-
|
|
2058
|
-
|
|
2059
|
-
...this.getClientSchemaObjectBoolean(),
|
|
2060
|
-
},
|
|
2053
|
+
fieldConfigurations: Array.from(this.fieldConfigurationByFieldPath.values()),
|
|
2054
|
+
subgraphConfigBySubgraphName,
|
|
2055
|
+
federatedGraphAST: newRouterAST,
|
|
2056
|
+
federatedGraphSchema: (0, graphql_1.buildASTSchema)(newRouterAST, { assumeValid: true, assumeValidSDL: true }),
|
|
2057
|
+
federatedGraphClientSchema: newClientSchema,
|
|
2058
|
+
parentDefinitionDataByTypeName: this.parentDefinitionDataByTypeName,
|
|
2059
|
+
success: true,
|
|
2061
2060
|
warnings: this.warnings,
|
|
2061
|
+
...this.getClientSchemaObjectBoolean(),
|
|
2062
2062
|
};
|
|
2063
2063
|
}
|
|
2064
2064
|
federateSubgraphsInternal() {
|
|
@@ -2069,20 +2069,20 @@ class FederationFactory {
|
|
|
2069
2069
|
exports.FederationFactory = FederationFactory;
|
|
2070
2070
|
function initializeFederationFactory(subgraphs) {
|
|
2071
2071
|
if (subgraphs.length < 1) {
|
|
2072
|
-
return { errors: [errors_1.minimumSubgraphRequirementError], warnings: [] };
|
|
2072
|
+
return { errors: [errors_1.minimumSubgraphRequirementError], success: false, warnings: [] };
|
|
2073
2073
|
}
|
|
2074
|
-
const
|
|
2075
|
-
if (
|
|
2076
|
-
return { errors, warnings };
|
|
2074
|
+
const result = (0, normalization_factory_1.batchNormalize)(subgraphs);
|
|
2075
|
+
if (!result.success) {
|
|
2076
|
+
return { errors: result.errors, success: false, warnings: result.warnings };
|
|
2077
2077
|
}
|
|
2078
2078
|
const entityInterfaceFederationDataByTypeName = new Map();
|
|
2079
2079
|
const invalidEntityInterfacesByTypeName = new Map();
|
|
2080
2080
|
const validEntityInterfaceTypeNames = new Set();
|
|
2081
|
-
for (const [subgraphName, internalSubgraph] of internalSubgraphBySubgraphName) {
|
|
2081
|
+
for (const [subgraphName, internalSubgraph] of result.internalSubgraphBySubgraphName) {
|
|
2082
2082
|
for (const [typeName, entityInterfaceData] of internalSubgraph.entityInterfaces) {
|
|
2083
2083
|
// Always add each entity interface to the invalid entity interfaces map
|
|
2084
2084
|
// If not, earlier checks would not account for implementations not yet seen
|
|
2085
|
-
(0,
|
|
2085
|
+
(0, utils_6.getValueOrDefault)(invalidEntityInterfacesByTypeName, typeName, () => []).push({
|
|
2086
2086
|
subgraphName,
|
|
2087
2087
|
concreteTypeNames: entityInterfaceData.concreteTypeNames || new Set(),
|
|
2088
2088
|
});
|
|
@@ -2107,47 +2107,50 @@ function initializeFederationFactory(subgraphs) {
|
|
|
2107
2107
|
errors: [
|
|
2108
2108
|
(0, errors_1.undefinedEntityInterfaceImplementationsError)(invalidEntityInterfacesByTypeName, entityInterfaceFederationDataByTypeName),
|
|
2109
2109
|
],
|
|
2110
|
-
|
|
2110
|
+
success: false,
|
|
2111
|
+
warnings: result.warnings,
|
|
2111
2112
|
};
|
|
2112
2113
|
}
|
|
2113
2114
|
return {
|
|
2114
2115
|
federationFactory: new FederationFactory({
|
|
2115
|
-
authorizationDataByParentTypeName,
|
|
2116
|
-
concreteTypeNamesByAbstractTypeName,
|
|
2117
|
-
entityDataByTypeName,
|
|
2116
|
+
authorizationDataByParentTypeName: result.authorizationDataByParentTypeName,
|
|
2117
|
+
concreteTypeNamesByAbstractTypeName: result.concreteTypeNamesByAbstractTypeName,
|
|
2118
|
+
entityDataByTypeName: result.entityDataByTypeName,
|
|
2118
2119
|
entityInterfaceFederationDataByTypeName,
|
|
2119
|
-
internalSubgraphBySubgraphName,
|
|
2120
|
-
internalGraph,
|
|
2121
|
-
warnings,
|
|
2120
|
+
internalSubgraphBySubgraphName: result.internalSubgraphBySubgraphName,
|
|
2121
|
+
internalGraph: result.internalGraph,
|
|
2122
|
+
warnings: result.warnings,
|
|
2122
2123
|
}),
|
|
2123
|
-
|
|
2124
|
+
success: true,
|
|
2125
|
+
warnings: result.warnings,
|
|
2124
2126
|
};
|
|
2125
2127
|
}
|
|
2126
2128
|
function federateSubgraphs(subgraphs) {
|
|
2127
|
-
const
|
|
2128
|
-
if (
|
|
2129
|
-
return { errors: errors
|
|
2129
|
+
const federationFactoryResult = initializeFederationFactory(subgraphs);
|
|
2130
|
+
if (!federationFactoryResult.success) {
|
|
2131
|
+
return { errors: federationFactoryResult.errors, success: false, warnings: federationFactoryResult.warnings };
|
|
2130
2132
|
}
|
|
2131
|
-
return federationFactory.federateSubgraphsInternal();
|
|
2133
|
+
return federationFactoryResult.federationFactory.federateSubgraphsInternal();
|
|
2132
2134
|
}
|
|
2133
2135
|
// the flow when publishing a subgraph that also has contracts
|
|
2134
2136
|
function federateSubgraphsWithContracts(subgraphs, tagOptionsByContractName) {
|
|
2135
|
-
const
|
|
2136
|
-
if (
|
|
2137
|
+
const factoryResult = initializeFederationFactory(subgraphs);
|
|
2138
|
+
if (!factoryResult.success) {
|
|
2137
2139
|
return {
|
|
2138
|
-
errors:
|
|
2139
|
-
|
|
2140
|
+
errors: factoryResult.errors,
|
|
2141
|
+
success: false,
|
|
2142
|
+
warnings: factoryResult.warnings,
|
|
2140
2143
|
};
|
|
2141
2144
|
}
|
|
2142
|
-
federationFactory.federateSubgraphData();
|
|
2143
|
-
const federationFactories = [(0, lodash_1.cloneDeep)(federationFactory)];
|
|
2144
|
-
const
|
|
2145
|
+
factoryResult.federationFactory.federateSubgraphData();
|
|
2146
|
+
const federationFactories = [(0, lodash_1.cloneDeep)(factoryResult.federationFactory)];
|
|
2147
|
+
const federationResult = factoryResult.federationFactory.buildFederationResult();
|
|
2145
2148
|
// if the base graph fails composition, no contracts will be attempted
|
|
2146
|
-
if (
|
|
2147
|
-
return { errors, warnings };
|
|
2149
|
+
if (!federationResult.success) {
|
|
2150
|
+
return { errors: federationResult.errors, success: false, warnings: federationResult.warnings };
|
|
2148
2151
|
}
|
|
2149
2152
|
const lastContractIndex = tagOptionsByContractName.size - 1;
|
|
2150
|
-
const
|
|
2153
|
+
const federationResultByContractName = new Map();
|
|
2151
2154
|
let i = 0;
|
|
2152
2155
|
for (const [contractName, tagOptions] of tagOptionsByContractName) {
|
|
2153
2156
|
// deep copy the current FederationFactory before it is mutated if it is not the last one required
|
|
@@ -2155,19 +2158,19 @@ function federateSubgraphsWithContracts(subgraphs, tagOptionsByContractName) {
|
|
|
2155
2158
|
federationFactories.push((0, lodash_1.cloneDeep)(federationFactories[i]));
|
|
2156
2159
|
}
|
|
2157
2160
|
// note that any one contract could have its own errors
|
|
2158
|
-
const
|
|
2159
|
-
|
|
2161
|
+
const contractResult = federationFactories[i].buildFederationContractResult(tagOptions);
|
|
2162
|
+
federationResultByContractName.set(contractName, contractResult);
|
|
2160
2163
|
i++;
|
|
2161
2164
|
}
|
|
2162
|
-
return { federationResult,
|
|
2165
|
+
return { ...federationResult, federationResultByContractName };
|
|
2163
2166
|
}
|
|
2164
2167
|
// the flow when adding a completely new contract
|
|
2165
2168
|
function federateSubgraphsContract(subgraphs, contractTagOptions) {
|
|
2166
|
-
const
|
|
2167
|
-
if (
|
|
2168
|
-
return { errors: errors
|
|
2169
|
+
const result = initializeFederationFactory(subgraphs);
|
|
2170
|
+
if (!result.success) {
|
|
2171
|
+
return { errors: result.errors, success: false, warnings: result.warnings };
|
|
2169
2172
|
}
|
|
2170
|
-
federationFactory.federateSubgraphData();
|
|
2171
|
-
return federationFactory.buildFederationContractResult(contractTagOptions);
|
|
2173
|
+
result.federationFactory.federateSubgraphData();
|
|
2174
|
+
return result.federationFactory.buildFederationContractResult(contractTagOptions);
|
|
2172
2175
|
}
|
|
2173
2176
|
//# sourceMappingURL=federation-factory.js.map
|