@wundergraph/composition 0.36.1 → 0.37.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/README.md +41 -48
- package/dist/ast/utils.d.ts +0 -2
- package/dist/ast/utils.js +2 -33
- package/dist/ast/utils.js.map +1 -1
- package/dist/errors/errors.d.ts +10 -13
- package/dist/errors/errors.js +81 -74
- 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 +24 -14
- package/dist/index.js +25 -14
- package/dist/index.js.map +1 -1
- package/dist/normalization/normalization.d.ts +8 -0
- package/dist/normalization/normalization.js +29 -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-nodes.d.ts +1 -1
- package/dist/resolvability-graph/graph-nodes.js.map +1 -1
- package/dist/resolvability-graph/graph.d.ts +1 -2
- package/dist/resolvability-graph/graph.js +21 -21
- package/dist/resolvability-graph/graph.js.map +1 -1
- package/dist/resolvability-graph/utils.d.ts +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/router-configuration/{router-configuration.d.ts → types.d.ts} +3 -4
- package/dist/router-configuration/types.js +3 -0
- package/dist/router-configuration/types.js.map +1 -0
- package/dist/router-configuration/utils.d.ts +3 -0
- package/dist/router-configuration/{router-configuration.js → utils.js} +9 -1
- package/dist/router-configuration/utils.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} +52 -5
- 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 +3 -11
- package/dist/schema-building/utils.js +16 -14
- package/dist/schema-building/utils.js.map +1 -1
- package/dist/subgraph/{subgraph.d.ts → types.d.ts} +6 -9
- 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 +5 -9
- package/dist/utils/string-constants.js +7 -33
- package/dist/utils/string-constants.js.map +1 -1
- package/dist/utils/types.d.ts +39 -0
- package/dist/utils/types.js +3 -0
- package/dist/utils/types.js.map +1 -0
- package/dist/utils/utils.d.ts +2 -114
- package/dist/utils/utils.js +33 -396
- 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 +244 -230
- package/dist/v1/federation/federation-factory.js.map +1 -0
- package/dist/v1/federation/utils.d.ts +59 -0
- package/dist/{federation → v1/federation}/utils.js +25 -23
- 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 +45 -73
- package/dist/{normalization → v1/normalization}/normalization-factory.js +763 -266
- package/dist/v1/normalization/normalization-factory.js.map +1 -0
- package/dist/v1/normalization/types.d.ts +49 -0
- package/dist/v1/normalization/types.js +3 -0
- package/dist/v1/normalization/types.js.map +1 -0
- package/dist/v1/normalization/utils.d.ts +14 -0
- package/dist/v1/normalization/utils.js +288 -0
- package/dist/v1/normalization/utils.js.map +1 -0
- package/dist/{normalization → v1/normalization}/walkers.js +69 -54
- 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 +38 -0
- package/dist/v1/utils/utils.js +336 -0
- package/dist/v1/utils/utils.js.map +1 -0
- package/dist/{warnings → v1/warnings}/warnings.d.ts +4 -13
- package/dist/{warnings → v1/warnings}/warnings.js +48 -27
- package/dist/v1/warnings/warnings.js.map +1 -0
- package/dist/warnings/types.d.ts +11 -0
- package/dist/warnings/types.js +13 -0
- package/dist/warnings/types.js.map +1 -0
- package/package.json +2 -2
- package/dist/federation/federation-factory.js.map +0 -1
- package/dist/federation/utils.d.ts +0 -84
- 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.d.ts +0 -49
- package/dist/normalization/utils.js +0 -612
- package/dist/normalization/utils.js.map +0 -1
- package/dist/normalization/walkers.js.map +0 -1
- package/dist/router-configuration/router-configuration.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/warnings/warnings.js.map +0 -1
- /package/dist/{normalization → v1/normalization}/walkers.d.ts +0 -0
- /package/dist/{subgraph → v1/subgraph}/subgraph.js +0 -0
|
@@ -5,26 +5,31 @@ exports.normalizeSubgraphFromString = normalizeSubgraphFromString;
|
|
|
5
5
|
exports.normalizeSubgraph = normalizeSubgraph;
|
|
6
6
|
exports.batchNormalize = batchNormalize;
|
|
7
7
|
const graphql_1 = require("graphql");
|
|
8
|
-
const utils_1 = require("
|
|
8
|
+
const utils_1 = require("../../ast/utils");
|
|
9
9
|
const utils_2 = require("./utils");
|
|
10
10
|
const constants_1 = require("../utils/constants");
|
|
11
11
|
const utils_3 = require("../utils/utils");
|
|
12
|
-
const errors_1 = require("
|
|
12
|
+
const errors_1 = require("../../errors/errors");
|
|
13
13
|
const string_constants_1 = require("../utils/string-constants");
|
|
14
|
-
const buildASTSchema_1 = require("
|
|
14
|
+
const buildASTSchema_1 = require("../../buildASTSchema/buildASTSchema");
|
|
15
15
|
const merge_1 = require("@graphql-tools/merge");
|
|
16
16
|
const subgraph_1 = require("../subgraph/subgraph");
|
|
17
17
|
const warnings_1 = require("../warnings/warnings");
|
|
18
18
|
const walkers_1 = require("./walkers");
|
|
19
|
-
const
|
|
20
|
-
const utils_4 = require("
|
|
21
|
-
const ast_1 = require("
|
|
22
|
-
const graph_1 = require("
|
|
19
|
+
const types_1 = require("../../schema-building/types");
|
|
20
|
+
const utils_4 = require("../../schema-building/utils");
|
|
21
|
+
const ast_1 = require("../../schema-building/ast");
|
|
22
|
+
const graph_1 = require("../../resolvability-graph/graph");
|
|
23
23
|
const integer_constants_1 = require("../utils/integer-constants");
|
|
24
|
+
const string_constants_2 = require("../../utils/string-constants");
|
|
25
|
+
const integer_constants_2 = require("../../utils/integer-constants");
|
|
26
|
+
const utils_5 = require("../../utils/utils");
|
|
27
|
+
const index_1 = require("graphql/index");
|
|
28
|
+
const utils_6 = require("../../router-configuration/utils");
|
|
24
29
|
function normalizeSubgraphFromString(subgraphSDL, noLocation = true) {
|
|
25
30
|
const { error, documentNode } = (0, utils_1.safeParse)(subgraphSDL, noLocation);
|
|
26
31
|
if (error || !documentNode) {
|
|
27
|
-
return { errors: [(0, errors_1.subgraphInvalidSyntaxError)(error)], warnings: [] };
|
|
32
|
+
return { errors: [(0, errors_1.subgraphInvalidSyntaxError)(error)], success: false, warnings: [] };
|
|
28
33
|
}
|
|
29
34
|
const normalizationFactory = new NormalizationFactory(new graph_1.Graph());
|
|
30
35
|
return normalizationFactory.normalize(documentNode);
|
|
@@ -38,8 +43,8 @@ class NormalizationFactory {
|
|
|
38
43
|
authorizationDataByParentTypeName = new Map();
|
|
39
44
|
childName = '';
|
|
40
45
|
concreteTypeNamesByAbstractTypeName = new Map();
|
|
41
|
-
|
|
42
|
-
|
|
46
|
+
conditionalFieldDataByCoords = new Map();
|
|
47
|
+
configurationDataByTypeName = new Map();
|
|
43
48
|
customDirectiveDefinitions = new Map();
|
|
44
49
|
definedDirectiveNames = new Set();
|
|
45
50
|
directiveDefinitionByDirectiveName = new Map();
|
|
@@ -49,7 +54,8 @@ class NormalizationFactory {
|
|
|
49
54
|
entityDataByTypeName = new Map();
|
|
50
55
|
entityInterfaceDataByTypeName = new Map();
|
|
51
56
|
eventsConfigurations = new Map();
|
|
52
|
-
|
|
57
|
+
fieldSetDataByTypeName = new Map();
|
|
58
|
+
heirFieldAuthorizationDataByTypeName = new Map();
|
|
53
59
|
interfaceTypeNamesWithAuthorizationDirectives = new Set();
|
|
54
60
|
internalGraph;
|
|
55
61
|
invalidConfigureDescriptionNodeDatas = [];
|
|
@@ -59,8 +65,7 @@ class NormalizationFactory {
|
|
|
59
65
|
isParentObjectShareable = false;
|
|
60
66
|
isSubgraphEventDrivenGraph = false;
|
|
61
67
|
isSubgraphVersionTwo = false;
|
|
62
|
-
|
|
63
|
-
heirFieldAuthorizationDataByTypeName = new Map();
|
|
68
|
+
keyFieldSetDatasByTypeName = new Map();
|
|
64
69
|
lastParentNodeKind = graphql_1.Kind.NULL;
|
|
65
70
|
lastChildNodeKind = graphql_1.Kind.NULL;
|
|
66
71
|
leafTypeNamesWithAuthorizationDirectives = new Set();
|
|
@@ -78,19 +83,20 @@ class NormalizationFactory {
|
|
|
78
83
|
referencedTypeNames = new Set();
|
|
79
84
|
renamedParentTypeName = '';
|
|
80
85
|
subgraphName;
|
|
86
|
+
unvalidatedExternalFieldCoords = new Set();
|
|
81
87
|
usesEdfsNatsStreamConfiguration = false;
|
|
82
88
|
warnings = [];
|
|
83
89
|
constructor(internalGraph, subgraphName) {
|
|
84
90
|
for (const [baseDirectiveName, baseDirectiveDefinition] of constants_1.BASE_DIRECTIVE_DEFINITION_BY_DIRECTIVE_NAME) {
|
|
85
91
|
this.directiveDefinitionByDirectiveName.set(baseDirectiveName, baseDirectiveDefinition);
|
|
86
92
|
}
|
|
87
|
-
this.subgraphName = subgraphName ||
|
|
93
|
+
this.subgraphName = subgraphName || string_constants_2.NOT_APPLICABLE;
|
|
88
94
|
this.internalGraph = internalGraph;
|
|
89
95
|
this.internalGraph.setSubgraphName(this.subgraphName);
|
|
90
96
|
this.schemaData = {
|
|
91
97
|
directivesByDirectiveName: new Map(),
|
|
92
98
|
kind: graphql_1.Kind.SCHEMA_DEFINITION,
|
|
93
|
-
name:
|
|
99
|
+
name: string_constants_2.SCHEMA,
|
|
94
100
|
operationTypes: new Map(),
|
|
95
101
|
};
|
|
96
102
|
}
|
|
@@ -109,7 +115,7 @@ class NormalizationFactory {
|
|
|
109
115
|
case graphql_1.Kind.SCALAR_TYPE_DEFINITION:
|
|
110
116
|
return { hasUnhandledError: false, typeString: '' };
|
|
111
117
|
default:
|
|
112
|
-
return { hasUnhandledError: true, typeString: (0,
|
|
118
|
+
return { hasUnhandledError: true, typeString: (0, utils_5.kindToTypeString)(parentData.kind) };
|
|
113
119
|
}
|
|
114
120
|
}
|
|
115
121
|
validateArguments(fieldData, fieldPath) {
|
|
@@ -142,7 +148,7 @@ class NormalizationFactory {
|
|
|
142
148
|
const requiresScopes = [];
|
|
143
149
|
for (const directiveNode of node.directives) {
|
|
144
150
|
const directiveName = directiveNode.name.value;
|
|
145
|
-
if (directiveName ===
|
|
151
|
+
if (directiveName === string_constants_2.AUTHENTICATED) {
|
|
146
152
|
// @authenticated is not repeatable
|
|
147
153
|
if (requiresAuthentication) {
|
|
148
154
|
return;
|
|
@@ -150,7 +156,7 @@ class NormalizationFactory {
|
|
|
150
156
|
requiresAuthentication = true;
|
|
151
157
|
continue;
|
|
152
158
|
}
|
|
153
|
-
if (directiveName !==
|
|
159
|
+
if (directiveName !== string_constants_2.REQUIRES_SCOPES) {
|
|
154
160
|
continue;
|
|
155
161
|
}
|
|
156
162
|
// @requiresScopes is not repeatable
|
|
@@ -178,7 +184,7 @@ class NormalizationFactory {
|
|
|
178
184
|
return;
|
|
179
185
|
}
|
|
180
186
|
const scopesArgument = directiveNode.arguments[0];
|
|
181
|
-
if (scopesArgument.name.value !==
|
|
187
|
+
if (scopesArgument.name.value !== string_constants_2.SCOPES || scopesArgument.value.kind !== graphql_1.Kind.LIST) {
|
|
182
188
|
return;
|
|
183
189
|
}
|
|
184
190
|
const orScopes = scopesArgument.value.values;
|
|
@@ -207,7 +213,7 @@ class NormalizationFactory {
|
|
|
207
213
|
return authorizationData;
|
|
208
214
|
}
|
|
209
215
|
isTypeNameRootType(typeName) {
|
|
210
|
-
return
|
|
216
|
+
return string_constants_2.ROOT_TYPE_NAMES.has(typeName) || this.operationTypeNodeByTypeName.has(typeName);
|
|
211
217
|
}
|
|
212
218
|
isArgumentValueValid(typeNode, argumentValue) {
|
|
213
219
|
if (argumentValue.kind === graphql_1.Kind.NULL) {
|
|
@@ -228,37 +234,37 @@ class NormalizationFactory {
|
|
|
228
234
|
}
|
|
229
235
|
case graphql_1.Kind.NAMED_TYPE: {
|
|
230
236
|
switch (typeNode.name.value) {
|
|
231
|
-
case
|
|
237
|
+
case string_constants_2.BOOLEAN_SCALAR: {
|
|
232
238
|
return argumentValue.kind === graphql_1.Kind.BOOLEAN;
|
|
233
239
|
}
|
|
234
|
-
case
|
|
240
|
+
case string_constants_2.FLOAT_SCALAR: {
|
|
235
241
|
return argumentValue.kind === graphql_1.Kind.FLOAT || argumentValue.kind === graphql_1.Kind.INT;
|
|
236
242
|
}
|
|
237
|
-
case
|
|
243
|
+
case string_constants_2.ID_SCALAR: {
|
|
238
244
|
return argumentValue.kind === graphql_1.Kind.STRING || argumentValue.kind === graphql_1.Kind.INT;
|
|
239
245
|
}
|
|
240
|
-
case
|
|
246
|
+
case string_constants_2.INT_SCALAR: {
|
|
241
247
|
return argumentValue.kind === graphql_1.Kind.INT;
|
|
242
248
|
}
|
|
243
|
-
case
|
|
249
|
+
case string_constants_2.FIELD_SET_SCALAR:
|
|
244
250
|
// intentional fallthrough
|
|
245
|
-
case
|
|
251
|
+
case string_constants_2.SCOPE_SCALAR:
|
|
246
252
|
// intentional fallthrough
|
|
247
|
-
case
|
|
253
|
+
case string_constants_2.STRING_SCALAR: {
|
|
248
254
|
return argumentValue.kind === graphql_1.Kind.STRING;
|
|
249
255
|
}
|
|
250
|
-
case
|
|
256
|
+
case string_constants_2.LINK_IMPORT: {
|
|
251
257
|
return true;
|
|
252
258
|
}
|
|
253
|
-
case
|
|
259
|
+
case string_constants_2.LINK_PURPOSE: {
|
|
254
260
|
if (argumentValue.kind !== graphql_1.Kind.ENUM) {
|
|
255
261
|
return false;
|
|
256
262
|
}
|
|
257
|
-
return argumentValue.value ===
|
|
263
|
+
return argumentValue.value === string_constants_2.SECURITY || argumentValue.value === string_constants_2.EXECUTION;
|
|
258
264
|
}
|
|
259
|
-
case
|
|
265
|
+
case string_constants_2.SUBSCRIPTION_FIELD_CONDITION:
|
|
260
266
|
// intentional fallthrough
|
|
261
|
-
case
|
|
267
|
+
case string_constants_2.SUBSCRIPTION_FILTER_CONDITION:
|
|
262
268
|
return argumentValue.kind === graphql_1.Kind.OBJECT;
|
|
263
269
|
default: {
|
|
264
270
|
const parentData = this.parentDefinitionDataByTypeName.get(typeNode.name.value);
|
|
@@ -277,7 +283,7 @@ class NormalizationFactory {
|
|
|
277
283
|
if (!enumValue) {
|
|
278
284
|
return false;
|
|
279
285
|
}
|
|
280
|
-
return !enumValue.directivesByDirectiveName.has(
|
|
286
|
+
return !enumValue.directivesByDirectiveName.has(string_constants_2.INACCESSIBLE);
|
|
281
287
|
}
|
|
282
288
|
if (parentData.kind !== graphql_1.Kind.INPUT_OBJECT_TYPE_DEFINITION) {
|
|
283
289
|
return false;
|
|
@@ -294,10 +300,10 @@ class NormalizationFactory {
|
|
|
294
300
|
}
|
|
295
301
|
addInheritedDirectivesToFieldData(fieldDirectivesByDirectiveName) {
|
|
296
302
|
if (this.isParentObjectShareable) {
|
|
297
|
-
(0,
|
|
303
|
+
(0, utils_5.getValueOrDefault)(fieldDirectivesByDirectiveName, string_constants_2.SHAREABLE, () => [(0, utils_5.generateSimpleDirective)(string_constants_2.SHAREABLE)]);
|
|
298
304
|
}
|
|
299
305
|
if (this.isParentObjectExternal) {
|
|
300
|
-
(0,
|
|
306
|
+
(0, utils_5.getValueOrDefault)(fieldDirectivesByDirectiveName, string_constants_2.EXTERNAL, () => [(0, utils_5.generateSimpleDirective)(string_constants_2.EXTERNAL)]);
|
|
301
307
|
}
|
|
302
308
|
return fieldDirectivesByDirectiveName;
|
|
303
309
|
}
|
|
@@ -308,26 +314,26 @@ class NormalizationFactory {
|
|
|
308
314
|
for (const directiveNode of node.directives) {
|
|
309
315
|
const directiveName = directiveNode.name.value;
|
|
310
316
|
// Don't create pointless repetitions of @shareable
|
|
311
|
-
if (directiveName ===
|
|
312
|
-
(0,
|
|
317
|
+
if (directiveName === string_constants_2.SHAREABLE) {
|
|
318
|
+
(0, utils_5.getValueOrDefault)(directivesByDirectiveName, directiveName, () => [directiveNode]);
|
|
313
319
|
}
|
|
314
320
|
else {
|
|
315
|
-
(0,
|
|
321
|
+
(0, utils_5.getValueOrDefault)(directivesByDirectiveName, directiveName, () => []).push(directiveNode);
|
|
316
322
|
}
|
|
317
323
|
if (!(0, utils_3.isNodeKindObject)(node.kind)) {
|
|
318
324
|
continue;
|
|
319
325
|
}
|
|
320
|
-
this.isParentObjectExternal ||= directiveName ===
|
|
321
|
-
this.isParentObjectShareable ||= directiveName ===
|
|
326
|
+
this.isParentObjectExternal ||= directiveName === string_constants_2.EXTERNAL;
|
|
327
|
+
this.isParentObjectShareable ||= directiveName === string_constants_2.SHAREABLE;
|
|
322
328
|
}
|
|
323
329
|
return directivesByDirectiveName;
|
|
324
330
|
}
|
|
325
331
|
validateDirective({ data, definitionData, directiveCoords, directiveNode, errorMessages, requiredArgumentNames, }) {
|
|
326
332
|
const directiveName = directiveNode.name.value;
|
|
327
333
|
const parentTypeName = data.kind === graphql_1.Kind.FIELD_DEFINITION ? data.renamedParentTypeName || data.originalParentTypeName : data.name;
|
|
328
|
-
const isAuthenticated = directiveName ===
|
|
329
|
-
const isOverride = directiveName ===
|
|
330
|
-
const isRequiresScopes = directiveName ===
|
|
334
|
+
const isAuthenticated = directiveName === string_constants_2.AUTHENTICATED;
|
|
335
|
+
const isOverride = directiveName === string_constants_2.OVERRIDE;
|
|
336
|
+
const isRequiresScopes = directiveName === string_constants_2.REQUIRES_SCOPES;
|
|
331
337
|
if (!directiveNode.arguments || directiveNode.arguments.length < 1) {
|
|
332
338
|
if (definitionData.requiredArgumentNames.size > 0) {
|
|
333
339
|
errorMessages.push((0, errors_1.undefinedRequiredArgumentsErrorMessage)(directiveName, requiredArgumentNames, []));
|
|
@@ -367,7 +373,7 @@ class NormalizationFactory {
|
|
|
367
373
|
});
|
|
368
374
|
continue;
|
|
369
375
|
}
|
|
370
|
-
if (!isRequiresScopes || argumentName !==
|
|
376
|
+
if (!isRequiresScopes || argumentName !== string_constants_2.SCOPES) {
|
|
371
377
|
continue;
|
|
372
378
|
}
|
|
373
379
|
this.handleRequiresScopesDirective({
|
|
@@ -383,7 +389,7 @@ class NormalizationFactory {
|
|
|
383
389
|
if (unexpectedArgumentNames.size > 0) {
|
|
384
390
|
errorMessages.push((0, errors_1.unexpectedDirectiveArgumentErrorMessage)(directiveName, [...unexpectedArgumentNames]));
|
|
385
391
|
}
|
|
386
|
-
const undefinedArgumentNames = (0,
|
|
392
|
+
const undefinedArgumentNames = (0, utils_5.getEntriesNotInHashSet)(requiredArgumentNames, definedArgumentNames);
|
|
387
393
|
if (undefinedArgumentNames.length > 0) {
|
|
388
394
|
errorMessages.push((0, errors_1.undefinedRequiredArgumentsErrorMessage)(directiveName, requiredArgumentNames, undefinedArgumentNames));
|
|
389
395
|
}
|
|
@@ -398,7 +404,7 @@ class NormalizationFactory {
|
|
|
398
404
|
if (data.kind !== graphql_1.Kind.FIELD_DEFINITION) {
|
|
399
405
|
this.leafTypeNamesWithAuthorizationDirectives.add(parentTypeName);
|
|
400
406
|
}
|
|
401
|
-
const parentAuthorizationData = (0,
|
|
407
|
+
const parentAuthorizationData = (0, utils_5.getValueOrDefault)(this.authorizationDataByParentTypeName, parentTypeName, () => (0, utils_3.newAuthorizationData)(parentTypeName));
|
|
402
408
|
const authorizationData = (0, utils_3.getAuthorizationDataToUpdate)(parentAuthorizationData, data.node);
|
|
403
409
|
authorizationData.requiredScopes.push(...requiredScopes);
|
|
404
410
|
return errorMessages;
|
|
@@ -420,7 +426,7 @@ class NormalizationFactory {
|
|
|
420
426
|
definitionErrorMessages.push((0, errors_1.invalidDirectiveLocationErrorMessage)(directiveName, directiveLocation));
|
|
421
427
|
}
|
|
422
428
|
if (directiveNodes.length > 1 && !definitionData.isRepeatable) {
|
|
423
|
-
const handledDirectiveNames = (0,
|
|
429
|
+
const handledDirectiveNames = (0, utils_5.getValueOrDefault)(this.invalidRepeatedDirectiveNameByCoords, directiveCoords, () => new Set());
|
|
424
430
|
if (!handledDirectiveNames.has(directiveName)) {
|
|
425
431
|
handledDirectiveNames.add(directiveName);
|
|
426
432
|
definitionErrorMessages.push((0, errors_1.invalidRepeatedDirectiveErrorMessage)(directiveName));
|
|
@@ -437,7 +443,7 @@ class NormalizationFactory {
|
|
|
437
443
|
requiredArgumentNames,
|
|
438
444
|
});
|
|
439
445
|
if (errorMessages.length > 0) {
|
|
440
|
-
this.errors.push((0, errors_1.invalidDirectiveError)(directiveName, directiveCoords, (0,
|
|
446
|
+
this.errors.push((0, errors_1.invalidDirectiveError)(directiveName, directiveCoords, (0, utils_5.numberToOrdinal)(i + 1), errorMessages));
|
|
441
447
|
}
|
|
442
448
|
}
|
|
443
449
|
}
|
|
@@ -480,29 +486,29 @@ class NormalizationFactory {
|
|
|
480
486
|
getNodeExtensionType(isRealExtension, directivesByDirectiveName, isRootType = false) {
|
|
481
487
|
// If the extend keyword is present, it's simply an extension
|
|
482
488
|
if (isRealExtension) {
|
|
483
|
-
return
|
|
489
|
+
return types_1.ExtensionType.REAL;
|
|
484
490
|
}
|
|
485
491
|
/*
|
|
486
492
|
* @extends is not interpreted as an extension under the following circumstances:
|
|
487
493
|
* 1. It's a root type
|
|
488
|
-
* 2. It's a V2 subgraph
|
|
494
|
+
* 2. It's a V2 subgraph (but extends is temporarily propagated to handle @external key fields)
|
|
489
495
|
* 3. And (of course) if @extends isn't defined at all
|
|
490
496
|
*/
|
|
491
|
-
if (isRootType ||
|
|
492
|
-
return
|
|
497
|
+
if (isRootType || !directivesByDirectiveName.has(string_constants_2.EXTENDS)) {
|
|
498
|
+
return types_1.ExtensionType.NONE;
|
|
493
499
|
}
|
|
494
|
-
// If
|
|
495
|
-
return
|
|
500
|
+
// If a V1 non-root Object defines @extends, it is considered an extension across subgraphs.
|
|
501
|
+
return types_1.ExtensionType.EXTENDS;
|
|
496
502
|
}
|
|
497
503
|
setParentDataExtensionType(parentData, incomingExtensionType) {
|
|
498
504
|
switch (parentData.extensionType) {
|
|
499
|
-
case
|
|
505
|
+
case types_1.ExtensionType.EXTENDS:
|
|
500
506
|
// intentional fallthrough
|
|
501
|
-
case
|
|
502
|
-
if (incomingExtensionType ===
|
|
507
|
+
case types_1.ExtensionType.NONE: {
|
|
508
|
+
if (incomingExtensionType === types_1.ExtensionType.REAL) {
|
|
503
509
|
return;
|
|
504
510
|
}
|
|
505
|
-
this.errors.push((0, errors_1.duplicateTypeDefinitionError)((0,
|
|
511
|
+
this.errors.push((0, errors_1.duplicateTypeDefinitionError)((0, utils_5.kindToTypeString)(parentData.kind), parentData.name));
|
|
506
512
|
return;
|
|
507
513
|
}
|
|
508
514
|
default: {
|
|
@@ -527,14 +533,14 @@ class NormalizationFactory {
|
|
|
527
533
|
};
|
|
528
534
|
for (const argument of directiveNode.arguments) {
|
|
529
535
|
switch (argument.name.value) {
|
|
530
|
-
case
|
|
536
|
+
case string_constants_2.PROPAGATE: {
|
|
531
537
|
if (argument.value.kind != graphql_1.Kind.BOOLEAN) {
|
|
532
538
|
return;
|
|
533
539
|
}
|
|
534
540
|
configureDescriptionData.propagate = argument.value.value;
|
|
535
541
|
break;
|
|
536
542
|
}
|
|
537
|
-
case
|
|
543
|
+
case string_constants_2.DESCRIPTION_OVERRIDE: {
|
|
538
544
|
if (argument.value.kind != graphql_1.Kind.STRING) {
|
|
539
545
|
return;
|
|
540
546
|
}
|
|
@@ -552,7 +558,7 @@ class NormalizationFactory {
|
|
|
552
558
|
data.configureDescriptionDataBySubgraphName.set(this.subgraphName, configureDescriptionData);
|
|
553
559
|
}
|
|
554
560
|
extractConfigureDescriptionsData(data) {
|
|
555
|
-
const configureDescriptionNodes = data.directivesByDirectiveName.get(
|
|
561
|
+
const configureDescriptionNodes = data.directivesByDirectiveName.get(string_constants_2.CONFIGURE_DESCRIPTION);
|
|
556
562
|
if (configureDescriptionNodes && configureDescriptionNodes.length == 1) {
|
|
557
563
|
this.extractConfigureDescriptionData(data, configureDescriptionNodes[0]);
|
|
558
564
|
}
|
|
@@ -581,13 +587,13 @@ class NormalizationFactory {
|
|
|
581
587
|
this.extractImplementedInterfaceTypeNames(node, data.implementedInterfaceTypeNames);
|
|
582
588
|
data.description ||= (0, utils_1.formatDescription)('description' in node ? node.description : undefined);
|
|
583
589
|
this.extractConfigureDescriptionsData(data);
|
|
584
|
-
data.isEntity ||= data.directivesByDirectiveName.has(
|
|
585
|
-
data.isInaccessible ||= data.directivesByDirectiveName.has(
|
|
590
|
+
data.isEntity ||= data.directivesByDirectiveName.has(string_constants_2.KEY);
|
|
591
|
+
data.isInaccessible ||= data.directivesByDirectiveName.has(string_constants_2.INACCESSIBLE);
|
|
586
592
|
data.subgraphNames.add(this.subgraphName);
|
|
587
593
|
}
|
|
588
594
|
addConcreteTypeNamesForImplementedInterfaces(interfaceTypeNames, concreteTypeName) {
|
|
589
595
|
for (const interfaceName of interfaceTypeNames) {
|
|
590
|
-
(0,
|
|
596
|
+
(0, utils_5.getValueOrDefault)(this.concreteTypeNamesByAbstractTypeName, interfaceName, () => new Set()).add(concreteTypeName);
|
|
591
597
|
this.internalGraph.addEdge(this.internalGraph.addOrUpdateNode(interfaceName, { isAbstract: true }), this.internalGraph.addOrUpdateNode(concreteTypeName), concreteTypeName, true);
|
|
592
598
|
}
|
|
593
599
|
}
|
|
@@ -637,7 +643,7 @@ class NormalizationFactory {
|
|
|
637
643
|
if (handledLocations.has(locationName)) {
|
|
638
644
|
continue;
|
|
639
645
|
}
|
|
640
|
-
if (!
|
|
646
|
+
if (!string_constants_2.EXECUTABLE_DIRECTIVE_LOCATIONS.has(locationName) && !string_constants_1.TYPE_SYSTEM_DIRECTIVE_LOCATIONS.has(locationName)) {
|
|
641
647
|
errorMessages.push((0, errors_1.invalidDirectiveDefinitionLocationErrorMessage)(locationName));
|
|
642
648
|
handledLocations.add(locationName);
|
|
643
649
|
continue;
|
|
@@ -722,27 +728,25 @@ class NormalizationFactory {
|
|
|
722
728
|
}
|
|
723
729
|
addFieldDataByNode(fieldDataByFieldName, node, argumentDataByArgumentName, directivesByDirectiveName) {
|
|
724
730
|
const name = node.name.value;
|
|
725
|
-
const
|
|
726
|
-
const
|
|
731
|
+
const fieldCoords = `${this.originalParentTypeName}.${name}`;
|
|
732
|
+
const { isExternal, isShareable } = (0, utils_4.isNodeExternalOrShareable)(node, !this.isSubgraphVersionTwo, directivesByDirectiveName);
|
|
727
733
|
const fieldData = {
|
|
728
734
|
argumentDataByArgumentName: argumentDataByArgumentName,
|
|
729
735
|
configureDescriptionDataBySubgraphName: new Map(),
|
|
730
|
-
|
|
731
|
-
[this.subgraphName,
|
|
732
|
-
]),
|
|
733
|
-
isInaccessible: directivesByDirectiveName.has(string_constants_1.INACCESSIBLE),
|
|
734
|
-
isShareableBySubgraphName: new Map([
|
|
735
|
-
[this.subgraphName, isNodeExternalOrShareableResult.isShareable],
|
|
736
|
+
externalFieldDataBySubgraphName: new Map([
|
|
737
|
+
[this.subgraphName, (0, utils_4.newExternalFieldData)(isExternal)],
|
|
736
738
|
]),
|
|
739
|
+
isInaccessible: directivesByDirectiveName.has(string_constants_2.INACCESSIBLE),
|
|
740
|
+
isShareableBySubgraphName: new Map([[this.subgraphName, isShareable]]),
|
|
737
741
|
kind: graphql_1.Kind.FIELD_DEFINITION,
|
|
738
742
|
name,
|
|
739
743
|
namedTypeName: (0, ast_1.getTypeNodeNamedTypeName)(node.type),
|
|
740
|
-
node: (0, ast_1.getMutableFieldNode)(node,
|
|
744
|
+
node: (0, ast_1.getMutableFieldNode)(node, fieldCoords, this.errors),
|
|
741
745
|
originalParentTypeName: this.originalParentTypeName,
|
|
742
746
|
persistedDirectivesData: (0, utils_4.newPersistedDirectivesData)(),
|
|
743
747
|
renamedParentTypeName: this.renamedParentTypeName || this.originalParentTypeName,
|
|
744
748
|
subgraphNames: new Set([this.subgraphName]),
|
|
745
|
-
type: (0, ast_1.getMutableTypeNode)(node.type,
|
|
749
|
+
type: (0, ast_1.getMutableTypeNode)(node.type, fieldCoords, this.errors),
|
|
746
750
|
directivesByDirectiveName,
|
|
747
751
|
description: (0, utils_1.formatDescription)(node.description),
|
|
748
752
|
};
|
|
@@ -755,7 +759,7 @@ class NormalizationFactory {
|
|
|
755
759
|
// Only arguments have renamed paths
|
|
756
760
|
const isArgument = !!renamedPath;
|
|
757
761
|
if (node.defaultValue && !(0, utils_4.areDefaultValuesCompatible)(node.type, node.defaultValue)) {
|
|
758
|
-
this.errors.push((0, errors_1.incompatibleInputValueDefaultValueTypeError)((isArgument ?
|
|
762
|
+
this.errors.push((0, errors_1.incompatibleInputValueDefaultValueTypeError)((isArgument ? string_constants_2.ARGUMENT : string_constants_2.INPUT_FIELD) + ` "${name}"`, originalPath, (0, merge_1.printTypeNode)(node.type), (0, graphql_1.print)(node.defaultValue)));
|
|
759
763
|
}
|
|
760
764
|
const inputValueData = {
|
|
761
765
|
configureDescriptionDataBySubgraphName: new Map(),
|
|
@@ -790,7 +794,7 @@ class NormalizationFactory {
|
|
|
790
794
|
}
|
|
791
795
|
if (parentData) {
|
|
792
796
|
if (parentData.kind !== graphql_1.Kind.INTERFACE_TYPE_DEFINITION) {
|
|
793
|
-
this.errors.push((0, errors_1.multipleNamedTypeDefinitionError)(typeName, (0,
|
|
797
|
+
this.errors.push((0, errors_1.multipleNamedTypeDefinitionError)(typeName, (0, utils_5.kindToTypeString)(parentData.kind), (0, utils_3.kindToConvertedTypeString)(node.kind)));
|
|
794
798
|
return;
|
|
795
799
|
}
|
|
796
800
|
this.updateCompositeOutputDataByNode(node, parentData, extensionType);
|
|
@@ -802,8 +806,8 @@ class NormalizationFactory {
|
|
|
802
806
|
extensionType,
|
|
803
807
|
fieldDataByFieldName: new Map(),
|
|
804
808
|
implementedInterfaceTypeNames: this.extractImplementedInterfaceTypeNames(node, new Set()),
|
|
805
|
-
isEntity: directivesByDirectiveName.has(
|
|
806
|
-
isInaccessible: directivesByDirectiveName.has(
|
|
809
|
+
isEntity: directivesByDirectiveName.has(string_constants_2.KEY),
|
|
810
|
+
isInaccessible: directivesByDirectiveName.has(string_constants_2.INACCESSIBLE),
|
|
807
811
|
kind: graphql_1.Kind.INTERFACE_TYPE_DEFINITION,
|
|
808
812
|
name: typeName,
|
|
809
813
|
node: (0, ast_1.getMutableInterfaceNode)(node.name),
|
|
@@ -821,11 +825,11 @@ class NormalizationFactory {
|
|
|
821
825
|
}
|
|
822
826
|
switch (operationTypeNode) {
|
|
823
827
|
case graphql_1.OperationTypeNode.MUTATION:
|
|
824
|
-
return
|
|
828
|
+
return string_constants_2.MUTATION;
|
|
825
829
|
case graphql_1.OperationTypeNode.SUBSCRIPTION:
|
|
826
|
-
return
|
|
830
|
+
return string_constants_2.SUBSCRIPTION;
|
|
827
831
|
default:
|
|
828
|
-
return
|
|
832
|
+
return string_constants_2.QUERY;
|
|
829
833
|
}
|
|
830
834
|
}
|
|
831
835
|
addInterfaceObjectFieldsByNode(node) {
|
|
@@ -847,7 +851,7 @@ class NormalizationFactory {
|
|
|
847
851
|
this.addInterfaceObjectFieldsByNode(node);
|
|
848
852
|
if (parentData) {
|
|
849
853
|
if (parentData.kind !== graphql_1.Kind.OBJECT_TYPE_DEFINITION) {
|
|
850
|
-
this.errors.push((0, errors_1.multipleNamedTypeDefinitionError)(typeName, (0,
|
|
854
|
+
this.errors.push((0, errors_1.multipleNamedTypeDefinitionError)(typeName, (0, utils_5.kindToTypeString)(parentData.kind), (0, utils_3.kindToConvertedTypeString)(node.kind)));
|
|
851
855
|
return;
|
|
852
856
|
}
|
|
853
857
|
this.updateCompositeOutputDataByNode(node, parentData, extensionType);
|
|
@@ -862,8 +866,8 @@ class NormalizationFactory {
|
|
|
862
866
|
extensionType,
|
|
863
867
|
fieldDataByFieldName: new Map(),
|
|
864
868
|
implementedInterfaceTypeNames,
|
|
865
|
-
isEntity: directivesByDirectiveName.has(
|
|
866
|
-
isInaccessible: directivesByDirectiveName.has(
|
|
869
|
+
isEntity: directivesByDirectiveName.has(string_constants_2.KEY),
|
|
870
|
+
isInaccessible: directivesByDirectiveName.has(string_constants_2.INACCESSIBLE),
|
|
867
871
|
isRootType,
|
|
868
872
|
kind: graphql_1.Kind.OBJECT_TYPE_DEFINITION,
|
|
869
873
|
name: typeName,
|
|
@@ -884,7 +888,7 @@ class NormalizationFactory {
|
|
|
884
888
|
const extensionType = this.getNodeExtensionType(isRealExtension, directivesByDirectiveName);
|
|
885
889
|
if (parentData) {
|
|
886
890
|
if (parentData.kind !== graphql_1.Kind.ENUM_TYPE_DEFINITION) {
|
|
887
|
-
this.errors.push((0, errors_1.multipleNamedTypeDefinitionError)(typeName, (0,
|
|
891
|
+
this.errors.push((0, errors_1.multipleNamedTypeDefinitionError)(typeName, (0, utils_5.kindToTypeString)(parentData.kind), (0, utils_3.kindToConvertedTypeString)(node.kind)));
|
|
888
892
|
return;
|
|
889
893
|
}
|
|
890
894
|
this.setParentDataExtensionType(parentData, extensionType);
|
|
@@ -916,11 +920,11 @@ class NormalizationFactory {
|
|
|
916
920
|
const extensionType = this.getNodeExtensionType(isRealExtension, directivesByDirectiveName);
|
|
917
921
|
if (parentData) {
|
|
918
922
|
if (parentData.kind !== graphql_1.Kind.INPUT_OBJECT_TYPE_DEFINITION) {
|
|
919
|
-
this.errors.push((0, errors_1.multipleNamedTypeDefinitionError)(typeName, (0,
|
|
923
|
+
this.errors.push((0, errors_1.multipleNamedTypeDefinitionError)(typeName, (0, utils_5.kindToTypeString)(parentData.kind), (0, utils_3.kindToConvertedTypeString)(node.kind)));
|
|
920
924
|
return;
|
|
921
925
|
}
|
|
922
926
|
this.setParentDataExtensionType(parentData, extensionType);
|
|
923
|
-
parentData.isInaccessible ||= directivesByDirectiveName.has(
|
|
927
|
+
parentData.isInaccessible ||= directivesByDirectiveName.has(string_constants_2.INACCESSIBLE);
|
|
924
928
|
parentData.subgraphNames.add(this.subgraphName);
|
|
925
929
|
parentData.description ||= (0, utils_1.formatDescription)('description' in node ? node.description : undefined);
|
|
926
930
|
this.extractConfigureDescriptionsData(parentData);
|
|
@@ -931,7 +935,7 @@ class NormalizationFactory {
|
|
|
931
935
|
directivesByDirectiveName,
|
|
932
936
|
extensionType,
|
|
933
937
|
inputValueDataByValueName: new Map(),
|
|
934
|
-
isInaccessible: directivesByDirectiveName.has(
|
|
938
|
+
isInaccessible: directivesByDirectiveName.has(string_constants_2.INACCESSIBLE),
|
|
935
939
|
kind: graphql_1.Kind.INPUT_OBJECT_TYPE_DEFINITION,
|
|
936
940
|
name: typeName,
|
|
937
941
|
node: (0, ast_1.getMutableInputObjectNode)(node.name),
|
|
@@ -950,7 +954,7 @@ class NormalizationFactory {
|
|
|
950
954
|
const extensionType = this.getNodeExtensionType(isRealExtension, directivesByDirectiveName);
|
|
951
955
|
if (parentData) {
|
|
952
956
|
if (parentData.kind !== graphql_1.Kind.SCALAR_TYPE_DEFINITION) {
|
|
953
|
-
this.errors.push((0, errors_1.multipleNamedTypeDefinitionError)(typeName, (0,
|
|
957
|
+
this.errors.push((0, errors_1.multipleNamedTypeDefinitionError)(typeName, (0, utils_5.kindToTypeString)(parentData.kind), (0, utils_3.kindToConvertedTypeString)(node.kind)));
|
|
954
958
|
return;
|
|
955
959
|
}
|
|
956
960
|
this.setParentDataExtensionType(parentData, extensionType);
|
|
@@ -982,7 +986,7 @@ class NormalizationFactory {
|
|
|
982
986
|
this.errors.push((0, errors_1.duplicateUnionMemberDefinitionError)(unionTypeName, memberTypeName));
|
|
983
987
|
continue;
|
|
984
988
|
}
|
|
985
|
-
(0,
|
|
989
|
+
(0, utils_5.getValueOrDefault)(this.concreteTypeNamesByAbstractTypeName, unionTypeName, () => new Set()).add(memberTypeName);
|
|
986
990
|
/*
|
|
987
991
|
* Scalars are never valid Union member types.
|
|
988
992
|
* However, base scalars are not upserted to the type definition data.
|
|
@@ -1005,7 +1009,7 @@ class NormalizationFactory {
|
|
|
1005
1009
|
this.addConcreteTypeNamesForUnion(node);
|
|
1006
1010
|
if (parentData) {
|
|
1007
1011
|
if (parentData.kind !== graphql_1.Kind.UNION_TYPE_DEFINITION) {
|
|
1008
|
-
this.errors.push((0, errors_1.multipleNamedTypeDefinitionError)(typeName, (0,
|
|
1012
|
+
this.errors.push((0, errors_1.multipleNamedTypeDefinitionError)(typeName, (0, utils_5.kindToTypeString)(parentData.kind), (0, utils_3.kindToConvertedTypeString)(node.kind)));
|
|
1009
1013
|
return;
|
|
1010
1014
|
}
|
|
1011
1015
|
this.setParentDataExtensionType(parentData, extensionType);
|
|
@@ -1028,51 +1032,373 @@ class NormalizationFactory {
|
|
|
1028
1032
|
this.extractConfigureDescriptionsData(newParentData);
|
|
1029
1033
|
this.parentDefinitionDataByTypeName.set(typeName, newParentData);
|
|
1030
1034
|
}
|
|
1031
|
-
extractKeyFieldSets(node,
|
|
1032
|
-
const isUnresolvableByRawKeyFieldSet = keyFieldSetData.isUnresolvableByKeyFieldSet;
|
|
1035
|
+
extractKeyFieldSets(node, keyFieldSetDataByFieldSet) {
|
|
1033
1036
|
const parentTypeName = node.name.value;
|
|
1034
1037
|
if (!node.directives?.length) {
|
|
1035
1038
|
// This should never happen
|
|
1036
1039
|
this.errors.push((0, errors_1.expectedEntityError)(parentTypeName));
|
|
1037
1040
|
return;
|
|
1038
1041
|
}
|
|
1039
|
-
// validation happens elsewhere
|
|
1042
|
+
// full validation happens elsewhere
|
|
1043
|
+
let keyNumber = 0;
|
|
1040
1044
|
for (const directive of node.directives) {
|
|
1041
|
-
if (directive.name.value !==
|
|
1045
|
+
if (directive.name.value !== string_constants_2.KEY) {
|
|
1042
1046
|
continue;
|
|
1043
1047
|
}
|
|
1048
|
+
keyNumber += 1;
|
|
1044
1049
|
if (!directive.arguments || directive.arguments.length < 1) {
|
|
1045
1050
|
continue;
|
|
1046
1051
|
}
|
|
1047
|
-
let
|
|
1052
|
+
let rawFieldSet;
|
|
1048
1053
|
let isUnresolvable = false;
|
|
1049
1054
|
for (const arg of directive.arguments) {
|
|
1050
|
-
if (arg.name.value ===
|
|
1055
|
+
if (arg.name.value === string_constants_2.RESOLVABLE) {
|
|
1051
1056
|
if (arg.value.kind === graphql_1.Kind.BOOLEAN && !arg.value.value) {
|
|
1052
1057
|
isUnresolvable = true;
|
|
1053
1058
|
}
|
|
1054
1059
|
continue;
|
|
1055
1060
|
}
|
|
1056
|
-
if (arg.name.value !==
|
|
1057
|
-
|
|
1061
|
+
if (arg.name.value !== string_constants_2.FIELDS) {
|
|
1062
|
+
rawFieldSet = undefined;
|
|
1058
1063
|
break;
|
|
1059
1064
|
}
|
|
1060
1065
|
if (arg.value.kind !== graphql_1.Kind.STRING) {
|
|
1061
|
-
|
|
1066
|
+
rawFieldSet = undefined;
|
|
1062
1067
|
break;
|
|
1063
1068
|
}
|
|
1064
|
-
|
|
1069
|
+
rawFieldSet = arg.value.value;
|
|
1070
|
+
}
|
|
1071
|
+
if (rawFieldSet === undefined) {
|
|
1072
|
+
continue;
|
|
1073
|
+
}
|
|
1074
|
+
const { error, documentNode } = (0, utils_1.safeParse)('{' + rawFieldSet + '}');
|
|
1075
|
+
if (error || !documentNode) {
|
|
1076
|
+
this.errors.push((0, errors_1.invalidDirectiveError)(string_constants_2.KEY, parentTypeName, (0, utils_5.numberToOrdinal)(keyNumber), [
|
|
1077
|
+
(0, errors_1.unparsableFieldSetErrorMessage)(rawFieldSet, error),
|
|
1078
|
+
]));
|
|
1079
|
+
continue;
|
|
1080
|
+
}
|
|
1081
|
+
const normalizedFieldSet = (0, utils_2.getNormalizedFieldSet)(documentNode);
|
|
1082
|
+
const keyFieldSetData = keyFieldSetDataByFieldSet.get(normalizedFieldSet);
|
|
1083
|
+
if (keyFieldSetData) {
|
|
1084
|
+
// Duplicate keys should potentially be a warning. For now, simply propagate if it's resolvable.
|
|
1085
|
+
keyFieldSetData.isUnresolvable ||= isUnresolvable;
|
|
1086
|
+
}
|
|
1087
|
+
else {
|
|
1088
|
+
keyFieldSetDataByFieldSet.set(normalizedFieldSet, {
|
|
1089
|
+
documentNode,
|
|
1090
|
+
isUnresolvable,
|
|
1091
|
+
normalizedFieldSet,
|
|
1092
|
+
rawFieldSet,
|
|
1093
|
+
});
|
|
1094
|
+
}
|
|
1095
|
+
}
|
|
1096
|
+
}
|
|
1097
|
+
getFieldSetParent(isProvides, parentData, fieldName, parentTypeName) {
|
|
1098
|
+
if (!isProvides) {
|
|
1099
|
+
return { fieldSetParentData: parentData };
|
|
1100
|
+
}
|
|
1101
|
+
const fieldData = (0, utils_5.getOrThrowError)(parentData.fieldDataByFieldName, fieldName, `${parentTypeName}.fieldDataByFieldName`);
|
|
1102
|
+
const fieldNamedTypeName = (0, ast_1.getTypeNodeNamedTypeName)(fieldData.node.type);
|
|
1103
|
+
const namedTypeData = this.parentDefinitionDataByTypeName.get(fieldNamedTypeName);
|
|
1104
|
+
// This error should never happen
|
|
1105
|
+
if (!namedTypeData) {
|
|
1106
|
+
return {
|
|
1107
|
+
errorString: (0, errors_1.unknownNamedTypeErrorMessage)(`${parentTypeName}.${fieldName}`, fieldNamedTypeName),
|
|
1108
|
+
};
|
|
1109
|
+
}
|
|
1110
|
+
if (namedTypeData.kind !== graphql_1.Kind.INTERFACE_TYPE_DEFINITION && namedTypeData.kind !== graphql_1.Kind.OBJECT_TYPE_DEFINITION) {
|
|
1111
|
+
return {
|
|
1112
|
+
errorString: (0, errors_1.incompatibleTypeWithProvidesErrorMessage)(`${parentTypeName}.${fieldName}`, fieldNamedTypeName),
|
|
1113
|
+
};
|
|
1114
|
+
}
|
|
1115
|
+
return { fieldSetParentData: namedTypeData };
|
|
1116
|
+
}
|
|
1117
|
+
validateConditionalFieldSet(selectionSetParentData, fieldSet, directiveFieldName, isProvides, directiveParentTypeName) {
|
|
1118
|
+
// Create a new selection set so that the value can be parsed as a new DocumentNode
|
|
1119
|
+
const { error, documentNode } = (0, utils_1.safeParse)('{' + fieldSet + '}');
|
|
1120
|
+
if (error || !documentNode) {
|
|
1121
|
+
return { errorMessages: [(0, errors_1.unparsableFieldSetErrorMessage)(fieldSet, error)] };
|
|
1122
|
+
}
|
|
1123
|
+
const nf = this;
|
|
1124
|
+
const parentDatas = [selectionSetParentData];
|
|
1125
|
+
const directiveName = (0, utils_2.getConditionalFieldSetDirectiveName)(isProvides);
|
|
1126
|
+
const definedFields = [];
|
|
1127
|
+
const directiveCoords = `${directiveParentTypeName}.${directiveFieldName}`;
|
|
1128
|
+
const fieldCoordsPath = (0, utils_2.getInitialFieldCoordsPath)(isProvides, directiveCoords);
|
|
1129
|
+
const fieldPath = [directiveFieldName];
|
|
1130
|
+
const externalAncestors = new Set();
|
|
1131
|
+
const errorMessages = [];
|
|
1132
|
+
let currentDepth = -1;
|
|
1133
|
+
let shouldDefineSelectionSet = true;
|
|
1134
|
+
let lastFieldName = directiveFieldName;
|
|
1135
|
+
let hasConditionalField = false;
|
|
1136
|
+
(0, index_1.visit)(documentNode, {
|
|
1137
|
+
Argument: {
|
|
1138
|
+
enter() {
|
|
1139
|
+
return false;
|
|
1140
|
+
},
|
|
1141
|
+
},
|
|
1142
|
+
Field: {
|
|
1143
|
+
enter(node) {
|
|
1144
|
+
const parentData = parentDatas[currentDepth];
|
|
1145
|
+
const parentTypeName = parentData.name;
|
|
1146
|
+
if (parentData.kind === graphql_1.Kind.UNION_TYPE_DEFINITION) {
|
|
1147
|
+
errorMessages.push((0, errors_1.invalidSelectionOnUnionErrorMessage)(fieldSet, fieldCoordsPath, parentTypeName));
|
|
1148
|
+
return index_1.BREAK;
|
|
1149
|
+
}
|
|
1150
|
+
const fieldName = node.name.value;
|
|
1151
|
+
const currentFieldCoords = `${parentTypeName}.${fieldName}`;
|
|
1152
|
+
nf.unvalidatedExternalFieldCoords.delete(currentFieldCoords);
|
|
1153
|
+
// If an object-like was just visited, a selection set should have been entered
|
|
1154
|
+
if (shouldDefineSelectionSet) {
|
|
1155
|
+
errorMessages.push((0, errors_1.invalidSelectionSetErrorMessage)(fieldSet, fieldCoordsPath, parentTypeName, (0, utils_5.kindToTypeString)(parentData.kind)));
|
|
1156
|
+
return index_1.BREAK;
|
|
1157
|
+
}
|
|
1158
|
+
fieldCoordsPath.push(currentFieldCoords);
|
|
1159
|
+
fieldPath.push(fieldName);
|
|
1160
|
+
lastFieldName = fieldName;
|
|
1161
|
+
const fieldData = parentData.fieldDataByFieldName.get(fieldName);
|
|
1162
|
+
// undefined if the field does not exist on the parent
|
|
1163
|
+
if (!fieldData) {
|
|
1164
|
+
errorMessages.push((0, errors_1.undefinedFieldInFieldSetErrorMessage)(fieldSet, parentTypeName, fieldName));
|
|
1165
|
+
return index_1.BREAK;
|
|
1166
|
+
}
|
|
1167
|
+
if (definedFields[currentDepth].has(fieldName)) {
|
|
1168
|
+
errorMessages.push((0, errors_1.duplicateFieldInFieldSetErrorMessage)(fieldSet, currentFieldCoords));
|
|
1169
|
+
return index_1.BREAK;
|
|
1170
|
+
}
|
|
1171
|
+
definedFields[currentDepth].add(fieldName);
|
|
1172
|
+
const { isDefinedExternal, isUnconditionallyProvided } = (0, utils_5.getOrThrowError)(fieldData.externalFieldDataBySubgraphName, nf.subgraphName, `${currentFieldCoords}.externalFieldDataBySubgraphName`);
|
|
1173
|
+
const isFieldConditional = isDefinedExternal && !isUnconditionallyProvided;
|
|
1174
|
+
if (!isUnconditionallyProvided) {
|
|
1175
|
+
hasConditionalField = true;
|
|
1176
|
+
}
|
|
1177
|
+
const namedTypeName = (0, ast_1.getTypeNodeNamedTypeName)(fieldData.node.type);
|
|
1178
|
+
// The child could itself be a parent
|
|
1179
|
+
const namedTypeData = nf.parentDefinitionDataByTypeName.get(namedTypeName);
|
|
1180
|
+
// The base scalars are not in the parents map
|
|
1181
|
+
if (constants_1.BASE_SCALARS.has(namedTypeName) ||
|
|
1182
|
+
namedTypeData?.kind === graphql_1.Kind.SCALAR_TYPE_DEFINITION ||
|
|
1183
|
+
namedTypeData?.kind === graphql_1.Kind.ENUM_TYPE_DEFINITION) {
|
|
1184
|
+
if (externalAncestors.size < 1 && !isDefinedExternal) {
|
|
1185
|
+
if (nf.isSubgraphVersionTwo) {
|
|
1186
|
+
nf.errors.push((0, errors_1.nonExternalConditionalFieldError)(directiveCoords, nf.subgraphName, currentFieldCoords, fieldSet, directiveName));
|
|
1187
|
+
return;
|
|
1188
|
+
}
|
|
1189
|
+
/* In V1, @requires and @provides do not need to declare any part of the field set @external.
|
|
1190
|
+
* It would appear that any such non-external fields are treated as if they are non-conditionally provided.
|
|
1191
|
+
* */
|
|
1192
|
+
nf.warnings.push((0, warnings_1.nonExternalConditionalFieldWarning)(directiveCoords, nf.subgraphName, currentFieldCoords, fieldSet, directiveName));
|
|
1193
|
+
return;
|
|
1194
|
+
}
|
|
1195
|
+
if (externalAncestors.size < 1 && isUnconditionallyProvided) {
|
|
1196
|
+
// V2 subgraphs return an error when an external key field on an entity extension is provided.
|
|
1197
|
+
if (nf.isSubgraphVersionTwo) {
|
|
1198
|
+
errorMessages.push((0, errors_1.fieldAlreadyProvidedErrorMessage)(currentFieldCoords, nf.subgraphName, directiveName));
|
|
1199
|
+
}
|
|
1200
|
+
else {
|
|
1201
|
+
nf.warnings.push((0, warnings_1.fieldAlreadyProvidedWarning)(currentFieldCoords, directiveName, directiveCoords, nf.subgraphName));
|
|
1202
|
+
}
|
|
1203
|
+
return;
|
|
1204
|
+
}
|
|
1205
|
+
// @TODO re-assess in v2 because this would be breaking for @provides in v1
|
|
1206
|
+
if (!isFieldConditional && !isProvides) {
|
|
1207
|
+
// Do not add unnecessary @requires configurations
|
|
1208
|
+
return;
|
|
1209
|
+
}
|
|
1210
|
+
const conditionalFieldData = (0, utils_5.getValueOrDefault)(nf.conditionalFieldDataByCoords, currentFieldCoords, utils_4.newConditionalFieldData);
|
|
1211
|
+
const fieldSetCondition = (0, utils_6.newFieldSetConditionData)({
|
|
1212
|
+
fieldCoordinatesPath: [...fieldCoordsPath],
|
|
1213
|
+
fieldPath: [...fieldPath],
|
|
1214
|
+
});
|
|
1215
|
+
isProvides
|
|
1216
|
+
? conditionalFieldData.providedBy.push(fieldSetCondition)
|
|
1217
|
+
: conditionalFieldData.requiredBy.push(fieldSetCondition);
|
|
1218
|
+
return;
|
|
1219
|
+
}
|
|
1220
|
+
if (!namedTypeData) {
|
|
1221
|
+
// Should not be possible to receive this error
|
|
1222
|
+
errorMessages.push((0, errors_1.unknownTypeInFieldSetErrorMessage)(fieldSet, currentFieldCoords, namedTypeName));
|
|
1223
|
+
return index_1.BREAK;
|
|
1224
|
+
}
|
|
1225
|
+
// TODO isFieldConditional
|
|
1226
|
+
if (isDefinedExternal) {
|
|
1227
|
+
if (isProvides) {
|
|
1228
|
+
(0, utils_5.getValueOrDefault)(nf.conditionalFieldDataByCoords, currentFieldCoords, utils_4.newConditionalFieldData).providedBy.push((0, utils_6.newFieldSetConditionData)({
|
|
1229
|
+
fieldCoordinatesPath: [...fieldCoordsPath],
|
|
1230
|
+
fieldPath: [...fieldPath],
|
|
1231
|
+
}));
|
|
1232
|
+
}
|
|
1233
|
+
externalAncestors.add(currentFieldCoords);
|
|
1234
|
+
}
|
|
1235
|
+
if (namedTypeData.kind === graphql_1.Kind.OBJECT_TYPE_DEFINITION ||
|
|
1236
|
+
namedTypeData.kind === graphql_1.Kind.INTERFACE_TYPE_DEFINITION ||
|
|
1237
|
+
namedTypeData.kind === graphql_1.Kind.UNION_TYPE_DEFINITION) {
|
|
1238
|
+
shouldDefineSelectionSet = true;
|
|
1239
|
+
parentDatas.push(namedTypeData);
|
|
1240
|
+
return;
|
|
1241
|
+
}
|
|
1242
|
+
},
|
|
1243
|
+
leave() {
|
|
1244
|
+
externalAncestors.delete(fieldCoordsPath.pop() || '');
|
|
1245
|
+
fieldPath.pop();
|
|
1246
|
+
},
|
|
1247
|
+
},
|
|
1248
|
+
InlineFragment: {
|
|
1249
|
+
enter(node) {
|
|
1250
|
+
const parentData = parentDatas[currentDepth];
|
|
1251
|
+
const parentTypeName = parentData.name;
|
|
1252
|
+
const fieldCoordinates = fieldCoordsPath.length < 1 ? selectionSetParentData.name : fieldCoordsPath[fieldCoordsPath.length - 1];
|
|
1253
|
+
if (!node.typeCondition) {
|
|
1254
|
+
errorMessages.push((0, errors_1.inlineFragmentWithoutTypeConditionErrorMessage)(fieldSet, fieldCoordinates));
|
|
1255
|
+
return index_1.BREAK;
|
|
1256
|
+
}
|
|
1257
|
+
const typeConditionName = node.typeCondition.name.value;
|
|
1258
|
+
// It's possible to infinitely define fragments
|
|
1259
|
+
if (typeConditionName === parentTypeName) {
|
|
1260
|
+
parentDatas.push(parentData);
|
|
1261
|
+
shouldDefineSelectionSet = true;
|
|
1262
|
+
return;
|
|
1263
|
+
}
|
|
1264
|
+
if (!(0, utils_1.isKindAbstract)(parentData.kind)) {
|
|
1265
|
+
errorMessages.push((0, errors_1.invalidInlineFragmentTypeErrorMessage)(fieldSet, fieldCoordsPath, typeConditionName, parentTypeName));
|
|
1266
|
+
return index_1.BREAK;
|
|
1267
|
+
}
|
|
1268
|
+
const fragmentNamedTypeData = nf.parentDefinitionDataByTypeName.get(typeConditionName);
|
|
1269
|
+
if (!fragmentNamedTypeData) {
|
|
1270
|
+
errorMessages.push((0, errors_1.unknownInlineFragmentTypeConditionErrorMessage)(fieldSet, fieldCoordsPath, parentTypeName, typeConditionName));
|
|
1271
|
+
return index_1.BREAK;
|
|
1272
|
+
}
|
|
1273
|
+
shouldDefineSelectionSet = true;
|
|
1274
|
+
switch (fragmentNamedTypeData.kind) {
|
|
1275
|
+
case graphql_1.Kind.INTERFACE_TYPE_DEFINITION: {
|
|
1276
|
+
if (!fragmentNamedTypeData.implementedInterfaceTypeNames.has(parentTypeName)) {
|
|
1277
|
+
break;
|
|
1278
|
+
}
|
|
1279
|
+
parentDatas.push(fragmentNamedTypeData);
|
|
1280
|
+
return;
|
|
1281
|
+
}
|
|
1282
|
+
case graphql_1.Kind.OBJECT_TYPE_DEFINITION: {
|
|
1283
|
+
const concreteTypeNames = nf.concreteTypeNamesByAbstractTypeName.get(parentTypeName);
|
|
1284
|
+
if (!concreteTypeNames || !concreteTypeNames.has(typeConditionName)) {
|
|
1285
|
+
break;
|
|
1286
|
+
}
|
|
1287
|
+
parentDatas.push(fragmentNamedTypeData);
|
|
1288
|
+
return;
|
|
1289
|
+
}
|
|
1290
|
+
case graphql_1.Kind.UNION_TYPE_DEFINITION: {
|
|
1291
|
+
parentDatas.push(fragmentNamedTypeData);
|
|
1292
|
+
return;
|
|
1293
|
+
}
|
|
1294
|
+
default: {
|
|
1295
|
+
errorMessages.push((0, errors_1.invalidInlineFragmentTypeConditionTypeErrorMessage)(fieldSet, fieldCoordsPath, parentTypeName, typeConditionName, (0, utils_5.kindToTypeString)(fragmentNamedTypeData.kind)));
|
|
1296
|
+
return index_1.BREAK;
|
|
1297
|
+
}
|
|
1298
|
+
}
|
|
1299
|
+
errorMessages.push((0, errors_1.invalidInlineFragmentTypeConditionErrorMessage)(fieldSet, fieldCoordsPath, typeConditionName, (0, utils_5.kindToTypeString)(parentData.kind), parentTypeName));
|
|
1300
|
+
return index_1.BREAK;
|
|
1301
|
+
},
|
|
1302
|
+
},
|
|
1303
|
+
SelectionSet: {
|
|
1304
|
+
enter() {
|
|
1305
|
+
if (!shouldDefineSelectionSet) {
|
|
1306
|
+
const parentData = parentDatas[currentDepth];
|
|
1307
|
+
if (parentData.kind === graphql_1.Kind.UNION_TYPE_DEFINITION) {
|
|
1308
|
+
// Should never happen
|
|
1309
|
+
errorMessages.push((0, errors_1.unparsableFieldSetSelectionErrorMessage)(fieldSet, lastFieldName));
|
|
1310
|
+
return index_1.BREAK;
|
|
1311
|
+
}
|
|
1312
|
+
const fieldData = parentData.fieldDataByFieldName.get(lastFieldName);
|
|
1313
|
+
if (!fieldData) {
|
|
1314
|
+
errorMessages.push((0, errors_1.undefinedFieldInFieldSetErrorMessage)(fieldSet, parentData.name, lastFieldName));
|
|
1315
|
+
return index_1.BREAK;
|
|
1316
|
+
}
|
|
1317
|
+
const fieldNamedTypeName = (0, ast_1.getTypeNodeNamedTypeName)(fieldData.node.type);
|
|
1318
|
+
// If the child is not found, it's a base scalar. Undefined types would have already been handled.
|
|
1319
|
+
const namedTypeData = nf.parentDefinitionDataByTypeName.get(fieldNamedTypeName);
|
|
1320
|
+
const childKind = namedTypeData ? namedTypeData.kind : graphql_1.Kind.SCALAR_TYPE_DEFINITION;
|
|
1321
|
+
errorMessages.push((0, errors_1.invalidSelectionSetDefinitionErrorMessage)(fieldSet, fieldCoordsPath, fieldNamedTypeName, (0, utils_5.kindToTypeString)(childKind)));
|
|
1322
|
+
return index_1.BREAK;
|
|
1323
|
+
}
|
|
1324
|
+
currentDepth += 1;
|
|
1325
|
+
shouldDefineSelectionSet = false;
|
|
1326
|
+
if (currentDepth < 0 || currentDepth >= parentDatas.length) {
|
|
1327
|
+
errorMessages.push((0, errors_1.unparsableFieldSetSelectionErrorMessage)(fieldSet, lastFieldName));
|
|
1328
|
+
return index_1.BREAK;
|
|
1329
|
+
}
|
|
1330
|
+
definedFields.push(new Set());
|
|
1331
|
+
},
|
|
1332
|
+
leave() {
|
|
1333
|
+
if (shouldDefineSelectionSet) {
|
|
1334
|
+
const parentData = parentDatas[currentDepth + 1];
|
|
1335
|
+
errorMessages.push((0, errors_1.invalidSelectionSetErrorMessage)(fieldSet, fieldCoordsPath, parentData.name, (0, utils_5.kindToTypeString)(parentData.kind)));
|
|
1336
|
+
shouldDefineSelectionSet = false;
|
|
1337
|
+
}
|
|
1338
|
+
// Empty selection sets would be a parse error, so it is unnecessary to handle them
|
|
1339
|
+
currentDepth -= 1;
|
|
1340
|
+
parentDatas.pop();
|
|
1341
|
+
definedFields.pop();
|
|
1342
|
+
},
|
|
1343
|
+
},
|
|
1344
|
+
});
|
|
1345
|
+
if (errorMessages.length > 0 || !hasConditionalField) {
|
|
1346
|
+
return { errorMessages };
|
|
1347
|
+
}
|
|
1348
|
+
return {
|
|
1349
|
+
configuration: { fieldName: directiveFieldName, selectionSet: (0, utils_2.getNormalizedFieldSet)(documentNode) },
|
|
1350
|
+
errorMessages,
|
|
1351
|
+
};
|
|
1352
|
+
}
|
|
1353
|
+
validateProvidesOrRequires(parentData, fieldSetByFieldName, isProvides) {
|
|
1354
|
+
const allErrorMessages = [];
|
|
1355
|
+
const configurations = [];
|
|
1356
|
+
const parentTypeName = (0, utils_4.getParentTypeName)(parentData);
|
|
1357
|
+
for (const [fieldName, fieldSet] of fieldSetByFieldName) {
|
|
1358
|
+
/* It is possible to encounter a field before encountering the type definition.
|
|
1359
|
+
Consequently, at that time, it is unknown whether the named type is an entity.
|
|
1360
|
+
If it isn't, the @provides directive does not make sense and can be ignored.
|
|
1361
|
+
*/
|
|
1362
|
+
const { fieldSetParentData, errorString } = this.getFieldSetParent(isProvides, parentData, fieldName, parentTypeName);
|
|
1363
|
+
const fieldCoords = `${parentTypeName}.${fieldName}`;
|
|
1364
|
+
if (errorString) {
|
|
1365
|
+
allErrorMessages.push(errorString);
|
|
1366
|
+
continue;
|
|
1065
1367
|
}
|
|
1066
|
-
if (
|
|
1067
|
-
|
|
1368
|
+
if (!fieldSetParentData) {
|
|
1369
|
+
continue;
|
|
1068
1370
|
}
|
|
1371
|
+
const { errorMessages, configuration } = this.validateConditionalFieldSet(fieldSetParentData, fieldSet, fieldName, isProvides, parentTypeName);
|
|
1372
|
+
/*
|
|
1373
|
+
* It is possible to return no error messages nor configuration if the @provides or @requires directive is
|
|
1374
|
+
* considered completely redundant, i.e.,:
|
|
1375
|
+
* 1. All fields to which the directive refers are declared @external but are also key fields on an entity extension.
|
|
1376
|
+
* 2. The subgraph is V1 and all fields to which the directive refers are not declared @external.
|
|
1377
|
+
* In these cases, the fields are considered unconditionally provided.
|
|
1378
|
+
* If all the fields to which the directive refers are unconditionally provided, the directive is redundant.
|
|
1379
|
+
* For V2 subgraphs, this will propagate as an error; for V1 subgraphs, this will propagate as a warning.
|
|
1380
|
+
* */
|
|
1381
|
+
if (errorMessages.length > 0) {
|
|
1382
|
+
allErrorMessages.push(` On field "${fieldCoords}":\n -` + errorMessages.join(string_constants_2.HYPHEN_JOIN));
|
|
1383
|
+
continue;
|
|
1384
|
+
}
|
|
1385
|
+
if (configuration) {
|
|
1386
|
+
configurations.push(configuration);
|
|
1387
|
+
}
|
|
1388
|
+
}
|
|
1389
|
+
if (allErrorMessages.length > 0) {
|
|
1390
|
+
this.errors.push((0, errors_1.invalidProvidesOrRequiresDirectivesError)((0, utils_2.getConditionalFieldSetDirectiveName)(isProvides), allErrorMessages));
|
|
1391
|
+
return;
|
|
1392
|
+
}
|
|
1393
|
+
if (configurations.length > 0) {
|
|
1394
|
+
return configurations;
|
|
1069
1395
|
}
|
|
1070
1396
|
}
|
|
1071
1397
|
validateInterfaceImplementations(data) {
|
|
1072
1398
|
if (data.implementedInterfaceTypeNames.size < 1) {
|
|
1073
1399
|
return;
|
|
1074
1400
|
}
|
|
1075
|
-
const isParentInaccessible = data.directivesByDirectiveName.has(
|
|
1401
|
+
const isParentInaccessible = data.directivesByDirectiveName.has(string_constants_2.INACCESSIBLE);
|
|
1076
1402
|
const implementationErrorsMap = new Map();
|
|
1077
1403
|
const invalidImplementationTypeStringByTypeName = new Map();
|
|
1078
1404
|
let doesInterfaceImplementItself = false;
|
|
@@ -1083,7 +1409,7 @@ class NormalizationFactory {
|
|
|
1083
1409
|
continue;
|
|
1084
1410
|
}
|
|
1085
1411
|
if (interfaceData.kind !== graphql_1.Kind.INTERFACE_TYPE_DEFINITION) {
|
|
1086
|
-
invalidImplementationTypeStringByTypeName.set(interfaceData.name, (0,
|
|
1412
|
+
invalidImplementationTypeStringByTypeName.set(interfaceData.name, (0, utils_5.kindToTypeString)(interfaceData.kind));
|
|
1087
1413
|
continue;
|
|
1088
1414
|
}
|
|
1089
1415
|
if (data.name === interfaceData.name) {
|
|
@@ -1169,7 +1495,7 @@ class NormalizationFactory {
|
|
|
1169
1495
|
this.errors.push((0, errors_1.selfImplementationError)(data.name));
|
|
1170
1496
|
}
|
|
1171
1497
|
if (implementationErrorsMap.size > 0) {
|
|
1172
|
-
this.errors.push((0, errors_1.invalidInterfaceImplementationError)(data.name, (0,
|
|
1498
|
+
this.errors.push((0, errors_1.invalidInterfaceImplementationError)(data.name, (0, utils_5.kindToTypeString)(data.kind), implementationErrorsMap));
|
|
1173
1499
|
}
|
|
1174
1500
|
}
|
|
1175
1501
|
handleAuthenticatedDirective(data, parentTypeName) {
|
|
@@ -1181,7 +1507,7 @@ class NormalizationFactory {
|
|
|
1181
1507
|
if (data.kind !== graphql_1.Kind.FIELD_DEFINITION) {
|
|
1182
1508
|
this.leafTypeNamesWithAuthorizationDirectives.add(parentTypeName);
|
|
1183
1509
|
}
|
|
1184
|
-
const parentAuthorizationData = (0,
|
|
1510
|
+
const parentAuthorizationData = (0, utils_5.getValueOrDefault)(this.authorizationDataByParentTypeName, parentTypeName, () => (0, utils_3.newAuthorizationData)(parentTypeName));
|
|
1185
1511
|
(0, utils_3.getAuthorizationDataToUpdate)(parentAuthorizationData, data.node).requiresAuthentication = true;
|
|
1186
1512
|
}
|
|
1187
1513
|
handleOverrideDirective({ data, directiveCoords, errorMessages, targetSubgraphName }) {
|
|
@@ -1189,8 +1515,8 @@ class NormalizationFactory {
|
|
|
1189
1515
|
errorMessages.push((0, errors_1.equivalentSourceAndTargetOverrideErrorMessage)(targetSubgraphName, directiveCoords));
|
|
1190
1516
|
return;
|
|
1191
1517
|
}
|
|
1192
|
-
const overrideDataForSubgraph = (0,
|
|
1193
|
-
(0,
|
|
1518
|
+
const overrideDataForSubgraph = (0, utils_5.getValueOrDefault)(this.overridesByTargetSubgraphName, targetSubgraphName, () => new Map());
|
|
1519
|
+
(0, utils_5.getValueOrDefault)(overrideDataForSubgraph, data.renamedParentTypeName || data.originalParentTypeName, () => new Set()).add(data.name);
|
|
1194
1520
|
}
|
|
1195
1521
|
handleRequiresScopesDirective({ directiveCoords, orScopes, requiredScopes }) {
|
|
1196
1522
|
if (orScopes.length > utils_3.maxOrScopes) {
|
|
@@ -1209,19 +1535,19 @@ class NormalizationFactory {
|
|
|
1209
1535
|
}
|
|
1210
1536
|
getKafkaPublishConfiguration(directive, argumentDataByArgumentName, errorMessages) {
|
|
1211
1537
|
const topics = [];
|
|
1212
|
-
let providerId =
|
|
1538
|
+
let providerId = string_constants_2.DEFAULT_EDFS_PROVIDER_ID;
|
|
1213
1539
|
for (const argumentNode of directive.arguments || []) {
|
|
1214
1540
|
switch (argumentNode.name.value) {
|
|
1215
|
-
case
|
|
1541
|
+
case string_constants_2.TOPIC: {
|
|
1216
1542
|
if (argumentNode.value.kind !== graphql_1.Kind.STRING || argumentNode.value.value.length < 1) {
|
|
1217
|
-
errorMessages.push((0, errors_1.invalidEventSubjectErrorMessage)(
|
|
1543
|
+
errorMessages.push((0, errors_1.invalidEventSubjectErrorMessage)(string_constants_2.TOPIC));
|
|
1218
1544
|
continue;
|
|
1219
1545
|
}
|
|
1220
1546
|
(0, utils_2.validateArgumentTemplateReferences)(argumentNode.value.value, argumentDataByArgumentName, errorMessages);
|
|
1221
1547
|
topics.push(argumentNode.value.value);
|
|
1222
1548
|
break;
|
|
1223
1549
|
}
|
|
1224
|
-
case
|
|
1550
|
+
case string_constants_2.PROVIDER_ID: {
|
|
1225
1551
|
if (argumentNode.value.kind !== graphql_1.Kind.STRING || argumentNode.value.value.length < 1) {
|
|
1226
1552
|
errorMessages.push(errors_1.invalidEventProviderIdErrorMessage);
|
|
1227
1553
|
continue;
|
|
@@ -1234,21 +1560,21 @@ class NormalizationFactory {
|
|
|
1234
1560
|
if (errorMessages.length > 0) {
|
|
1235
1561
|
return;
|
|
1236
1562
|
}
|
|
1237
|
-
return { fieldName: this.childName, providerId, providerType:
|
|
1563
|
+
return { fieldName: this.childName, providerId, providerType: string_constants_2.PROVIDER_TYPE_KAFKA, topics, type: string_constants_2.PUBLISH };
|
|
1238
1564
|
}
|
|
1239
1565
|
getKafkaSubscribeConfiguration(directive, argumentDataByArgumentName, errorMessages) {
|
|
1240
1566
|
const topics = [];
|
|
1241
|
-
let providerId =
|
|
1567
|
+
let providerId = string_constants_2.DEFAULT_EDFS_PROVIDER_ID;
|
|
1242
1568
|
for (const argumentNode of directive.arguments || []) {
|
|
1243
1569
|
switch (argumentNode.name.value) {
|
|
1244
|
-
case
|
|
1570
|
+
case string_constants_2.TOPICS: {
|
|
1245
1571
|
if (argumentNode.value.kind !== graphql_1.Kind.LIST) {
|
|
1246
|
-
errorMessages.push((0, errors_1.invalidEventSubjectsErrorMessage)(
|
|
1572
|
+
errorMessages.push((0, errors_1.invalidEventSubjectsErrorMessage)(string_constants_2.TOPICS));
|
|
1247
1573
|
continue;
|
|
1248
1574
|
}
|
|
1249
1575
|
for (const value of argumentNode.value.values) {
|
|
1250
1576
|
if (value.kind !== graphql_1.Kind.STRING || value.value.length < 1) {
|
|
1251
|
-
errorMessages.push((0, errors_1.invalidEventSubjectsItemErrorMessage)(
|
|
1577
|
+
errorMessages.push((0, errors_1.invalidEventSubjectsItemErrorMessage)(string_constants_2.TOPICS));
|
|
1252
1578
|
break;
|
|
1253
1579
|
}
|
|
1254
1580
|
(0, utils_2.validateArgumentTemplateReferences)(value.value, argumentDataByArgumentName, errorMessages);
|
|
@@ -1256,7 +1582,7 @@ class NormalizationFactory {
|
|
|
1256
1582
|
}
|
|
1257
1583
|
break;
|
|
1258
1584
|
}
|
|
1259
|
-
case
|
|
1585
|
+
case string_constants_2.PROVIDER_ID: {
|
|
1260
1586
|
if (argumentNode.value.kind !== graphql_1.Kind.STRING || argumentNode.value.value.length < 1) {
|
|
1261
1587
|
errorMessages.push(errors_1.invalidEventProviderIdErrorMessage);
|
|
1262
1588
|
continue;
|
|
@@ -1272,26 +1598,26 @@ class NormalizationFactory {
|
|
|
1272
1598
|
return {
|
|
1273
1599
|
fieldName: this.childName,
|
|
1274
1600
|
providerId,
|
|
1275
|
-
providerType:
|
|
1601
|
+
providerType: string_constants_2.PROVIDER_TYPE_KAFKA,
|
|
1276
1602
|
topics: topics,
|
|
1277
|
-
type:
|
|
1603
|
+
type: string_constants_2.SUBSCRIBE,
|
|
1278
1604
|
};
|
|
1279
1605
|
}
|
|
1280
1606
|
getNatsPublishAndRequestConfiguration(eventType, directive, argumentDataByArgumentName, errorMessages) {
|
|
1281
1607
|
const subjects = [];
|
|
1282
|
-
let providerId =
|
|
1608
|
+
let providerId = string_constants_2.DEFAULT_EDFS_PROVIDER_ID;
|
|
1283
1609
|
for (const argumentNode of directive.arguments || []) {
|
|
1284
1610
|
switch (argumentNode.name.value) {
|
|
1285
|
-
case
|
|
1611
|
+
case string_constants_2.SUBJECT: {
|
|
1286
1612
|
if (argumentNode.value.kind !== graphql_1.Kind.STRING || argumentNode.value.value.length < 1) {
|
|
1287
|
-
errorMessages.push((0, errors_1.invalidEventSubjectErrorMessage)(
|
|
1613
|
+
errorMessages.push((0, errors_1.invalidEventSubjectErrorMessage)(string_constants_2.SUBJECT));
|
|
1288
1614
|
continue;
|
|
1289
1615
|
}
|
|
1290
1616
|
(0, utils_2.validateArgumentTemplateReferences)(argumentNode.value.value, argumentDataByArgumentName, errorMessages);
|
|
1291
1617
|
subjects.push(argumentNode.value.value);
|
|
1292
1618
|
break;
|
|
1293
1619
|
}
|
|
1294
|
-
case
|
|
1620
|
+
case string_constants_2.PROVIDER_ID: {
|
|
1295
1621
|
if (argumentNode.value.kind !== graphql_1.Kind.STRING || argumentNode.value.value.length < 1) {
|
|
1296
1622
|
errorMessages.push(errors_1.invalidEventProviderIdErrorMessage);
|
|
1297
1623
|
continue;
|
|
@@ -1304,24 +1630,24 @@ class NormalizationFactory {
|
|
|
1304
1630
|
if (errorMessages.length > 0) {
|
|
1305
1631
|
return;
|
|
1306
1632
|
}
|
|
1307
|
-
return { fieldName: this.childName, providerId, providerType:
|
|
1633
|
+
return { fieldName: this.childName, providerId, providerType: string_constants_2.PROVIDER_TYPE_NATS, subjects, type: eventType };
|
|
1308
1634
|
}
|
|
1309
1635
|
getNatsSubscribeConfiguration(directive, argumentDataByArgumentName, errorMessages) {
|
|
1310
1636
|
const subjects = [];
|
|
1311
|
-
let providerId =
|
|
1637
|
+
let providerId = string_constants_2.DEFAULT_EDFS_PROVIDER_ID;
|
|
1312
1638
|
let consumerInactiveThreshold = integer_constants_1.DEFAULT_CONSUMER_INACTIVE_THRESHOLD;
|
|
1313
1639
|
let consumerName = '';
|
|
1314
1640
|
let streamName = '';
|
|
1315
1641
|
for (const argumentNode of directive.arguments || []) {
|
|
1316
1642
|
switch (argumentNode.name.value) {
|
|
1317
|
-
case
|
|
1643
|
+
case string_constants_2.SUBJECTS: {
|
|
1318
1644
|
if (argumentNode.value.kind !== graphql_1.Kind.LIST) {
|
|
1319
1645
|
// errorMessages.push(invalidEventSubjectsErrorMessage(SUBJECTS));
|
|
1320
1646
|
continue;
|
|
1321
1647
|
}
|
|
1322
1648
|
for (const value of argumentNode.value.values) {
|
|
1323
1649
|
if (value.kind !== graphql_1.Kind.STRING || value.value.length < 1) {
|
|
1324
|
-
errorMessages.push((0, errors_1.invalidEventSubjectsItemErrorMessage)(
|
|
1650
|
+
errorMessages.push((0, errors_1.invalidEventSubjectsItemErrorMessage)(string_constants_2.SUBJECTS));
|
|
1325
1651
|
break;
|
|
1326
1652
|
}
|
|
1327
1653
|
(0, utils_2.validateArgumentTemplateReferences)(value.value, argumentDataByArgumentName, errorMessages);
|
|
@@ -1329,7 +1655,7 @@ class NormalizationFactory {
|
|
|
1329
1655
|
}
|
|
1330
1656
|
break;
|
|
1331
1657
|
}
|
|
1332
|
-
case
|
|
1658
|
+
case string_constants_2.PROVIDER_ID: {
|
|
1333
1659
|
if (argumentNode.value.kind !== graphql_1.Kind.STRING || argumentNode.value.value.length < 1) {
|
|
1334
1660
|
errorMessages.push(errors_1.invalidEventProviderIdErrorMessage);
|
|
1335
1661
|
continue;
|
|
@@ -1337,7 +1663,7 @@ class NormalizationFactory {
|
|
|
1337
1663
|
providerId = argumentNode.value.value;
|
|
1338
1664
|
break;
|
|
1339
1665
|
}
|
|
1340
|
-
case
|
|
1666
|
+
case string_constants_2.STREAM_CONFIGURATION: {
|
|
1341
1667
|
this.usesEdfsNatsStreamConfiguration = true;
|
|
1342
1668
|
if (argumentNode.value.kind !== graphql_1.Kind.OBJECT || argumentNode.value.fields.length < 1) {
|
|
1343
1669
|
errorMessages.push(errors_1.invalidNatsStreamInputErrorMessage);
|
|
@@ -1346,7 +1672,7 @@ class NormalizationFactory {
|
|
|
1346
1672
|
let isValid = true;
|
|
1347
1673
|
const invalidFieldNames = new Set();
|
|
1348
1674
|
const allowedFieldNames = new Set(string_constants_1.STREAM_CONFIGURATION_FIELD_NAMES);
|
|
1349
|
-
const missingRequiredFieldNames = new Set([
|
|
1675
|
+
const missingRequiredFieldNames = new Set([string_constants_2.CONSUMER_NAME, string_constants_2.STREAM_NAME]);
|
|
1350
1676
|
const duplicateFieldNames = new Set();
|
|
1351
1677
|
const invalidRequiredFieldNames = new Set();
|
|
1352
1678
|
for (const field of argumentNode.value.fields) {
|
|
@@ -1368,7 +1694,7 @@ class NormalizationFactory {
|
|
|
1368
1694
|
missingRequiredFieldNames.delete(fieldName);
|
|
1369
1695
|
}
|
|
1370
1696
|
switch (fieldName) {
|
|
1371
|
-
case
|
|
1697
|
+
case string_constants_2.CONSUMER_NAME:
|
|
1372
1698
|
if (field.value.kind != graphql_1.Kind.STRING || field.value.value.length < 1) {
|
|
1373
1699
|
invalidRequiredFieldNames.add(fieldName);
|
|
1374
1700
|
isValid = false;
|
|
@@ -1376,7 +1702,7 @@ class NormalizationFactory {
|
|
|
1376
1702
|
}
|
|
1377
1703
|
consumerName = field.value.value;
|
|
1378
1704
|
break;
|
|
1379
|
-
case
|
|
1705
|
+
case string_constants_2.STREAM_NAME:
|
|
1380
1706
|
if (field.value.kind != graphql_1.Kind.STRING || field.value.value.length < 1) {
|
|
1381
1707
|
invalidRequiredFieldNames.add(fieldName);
|
|
1382
1708
|
isValid = false;
|
|
@@ -1384,9 +1710,9 @@ class NormalizationFactory {
|
|
|
1384
1710
|
}
|
|
1385
1711
|
streamName = field.value.value;
|
|
1386
1712
|
break;
|
|
1387
|
-
case
|
|
1713
|
+
case string_constants_2.CONSUMER_INACTIVE_THRESHOLD:
|
|
1388
1714
|
if (field.value.kind != graphql_1.Kind.INT) {
|
|
1389
|
-
errorMessages.push((0, errors_1.invalidArgumentValueErrorMessage)((0, graphql_1.print)(field.value), 'edfs__NatsStreamConfiguration', `consumerInactiveThreshold`,
|
|
1715
|
+
errorMessages.push((0, errors_1.invalidArgumentValueErrorMessage)((0, graphql_1.print)(field.value), 'edfs__NatsStreamConfiguration', `consumerInactiveThreshold`, string_constants_2.INT_SCALAR));
|
|
1390
1716
|
isValid = false;
|
|
1391
1717
|
continue;
|
|
1392
1718
|
}
|
|
@@ -1395,7 +1721,7 @@ class NormalizationFactory {
|
|
|
1395
1721
|
consumerInactiveThreshold = parseInt(field.value.value, 10);
|
|
1396
1722
|
}
|
|
1397
1723
|
catch (e) {
|
|
1398
|
-
errorMessages.push((0, errors_1.invalidArgumentValueErrorMessage)((0, graphql_1.print)(field.value), 'edfs__NatsStreamConfiguration', `consumerInactiveThreshold`,
|
|
1724
|
+
errorMessages.push((0, errors_1.invalidArgumentValueErrorMessage)((0, graphql_1.print)(field.value), 'edfs__NatsStreamConfiguration', `consumerInactiveThreshold`, string_constants_2.INT_SCALAR));
|
|
1399
1725
|
isValid = false;
|
|
1400
1726
|
}
|
|
1401
1727
|
break;
|
|
@@ -1414,16 +1740,16 @@ class NormalizationFactory {
|
|
|
1414
1740
|
consumerInactiveThreshold = integer_constants_1.DEFAULT_CONSUMER_INACTIVE_THRESHOLD;
|
|
1415
1741
|
this.warnings.push((0, warnings_1.consumerInactiveThresholdInvalidValueWarning)(this.subgraphName, `The value has been set to ${integer_constants_1.DEFAULT_CONSUMER_INACTIVE_THRESHOLD}.`));
|
|
1416
1742
|
}
|
|
1417
|
-
else if (consumerInactiveThreshold >
|
|
1743
|
+
else if (consumerInactiveThreshold > integer_constants_2.MAX_INT32) {
|
|
1418
1744
|
consumerInactiveThreshold = 0;
|
|
1419
1745
|
this.warnings.push((0, warnings_1.consumerInactiveThresholdInvalidValueWarning)(this.subgraphName, 'The value has been set to 0. This means the consumer will remain indefinitely active until its manual deletion.'));
|
|
1420
1746
|
}
|
|
1421
1747
|
return {
|
|
1422
1748
|
fieldName: this.childName,
|
|
1423
1749
|
providerId,
|
|
1424
|
-
providerType:
|
|
1750
|
+
providerType: string_constants_2.PROVIDER_TYPE_NATS,
|
|
1425
1751
|
subjects,
|
|
1426
|
-
type:
|
|
1752
|
+
type: string_constants_2.SUBSCRIBE,
|
|
1427
1753
|
...(consumerName && streamName
|
|
1428
1754
|
? {
|
|
1429
1755
|
streamConfiguration: {
|
|
@@ -1443,7 +1769,7 @@ class NormalizationFactory {
|
|
|
1443
1769
|
const fieldPath = `${parentTypeName}.${node.name.value}`;
|
|
1444
1770
|
const isSubscription = this.getOperationTypeNodeForRootTypeName(parentTypeName) === graphql_1.OperationTypeNode.SUBSCRIPTION;
|
|
1445
1771
|
for (const directiveNode of node.directives) {
|
|
1446
|
-
if (directiveNode.name.value !==
|
|
1772
|
+
if (directiveNode.name.value !== string_constants_2.SUBSCRIPTION_FILTER) {
|
|
1447
1773
|
continue;
|
|
1448
1774
|
}
|
|
1449
1775
|
if (!isSubscription) {
|
|
@@ -1462,21 +1788,21 @@ class NormalizationFactory {
|
|
|
1462
1788
|
const errorMessages = [];
|
|
1463
1789
|
let eventConfiguration;
|
|
1464
1790
|
switch (directive.name.value) {
|
|
1465
|
-
case
|
|
1791
|
+
case string_constants_2.EDFS_KAFKA_PUBLISH:
|
|
1466
1792
|
eventConfiguration = this.getKafkaPublishConfiguration(directive, argumentDataByArgumentName, errorMessages);
|
|
1467
1793
|
break;
|
|
1468
|
-
case
|
|
1794
|
+
case string_constants_2.EDFS_KAFKA_SUBSCRIBE:
|
|
1469
1795
|
eventConfiguration = this.getKafkaSubscribeConfiguration(directive, argumentDataByArgumentName, errorMessages);
|
|
1470
1796
|
break;
|
|
1471
|
-
case
|
|
1472
|
-
eventConfiguration = this.getNatsPublishAndRequestConfiguration(
|
|
1797
|
+
case string_constants_2.EDFS_NATS_PUBLISH: {
|
|
1798
|
+
eventConfiguration = this.getNatsPublishAndRequestConfiguration(string_constants_2.PUBLISH, directive, argumentDataByArgumentName, errorMessages);
|
|
1473
1799
|
break;
|
|
1474
1800
|
}
|
|
1475
|
-
case
|
|
1476
|
-
eventConfiguration = this.getNatsPublishAndRequestConfiguration(
|
|
1801
|
+
case string_constants_2.EDFS_NATS_REQUEST: {
|
|
1802
|
+
eventConfiguration = this.getNatsPublishAndRequestConfiguration(string_constants_2.REQUEST, directive, argumentDataByArgumentName, errorMessages);
|
|
1477
1803
|
break;
|
|
1478
1804
|
}
|
|
1479
|
-
case
|
|
1805
|
+
case string_constants_2.EDFS_NATS_SUBSCRIBE: {
|
|
1480
1806
|
eventConfiguration = this.getNatsSubscribeConfiguration(directive, argumentDataByArgumentName, errorMessages);
|
|
1481
1807
|
break;
|
|
1482
1808
|
}
|
|
@@ -1491,17 +1817,17 @@ class NormalizationFactory {
|
|
|
1491
1817
|
if (!eventConfiguration) {
|
|
1492
1818
|
continue;
|
|
1493
1819
|
}
|
|
1494
|
-
(0,
|
|
1820
|
+
(0, utils_5.getValueOrDefault)(this.eventsConfigurations, this.renamedParentTypeName || this.originalParentTypeName, () => []).push(eventConfiguration);
|
|
1495
1821
|
}
|
|
1496
1822
|
}
|
|
1497
1823
|
getValidEventsDirectiveNamesForOperationTypeNode(operationTypeNode) {
|
|
1498
1824
|
switch (operationTypeNode) {
|
|
1499
1825
|
case graphql_1.OperationTypeNode.MUTATION:
|
|
1500
|
-
return new Set([
|
|
1826
|
+
return new Set([string_constants_2.EDFS_KAFKA_PUBLISH, string_constants_2.EDFS_NATS_PUBLISH, string_constants_2.EDFS_NATS_REQUEST]);
|
|
1501
1827
|
case graphql_1.OperationTypeNode.QUERY:
|
|
1502
|
-
return new Set([
|
|
1828
|
+
return new Set([string_constants_2.EDFS_NATS_REQUEST]);
|
|
1503
1829
|
case graphql_1.OperationTypeNode.SUBSCRIPTION:
|
|
1504
|
-
return new Set([
|
|
1830
|
+
return new Set([string_constants_2.EDFS_KAFKA_SUBSCRIBE, string_constants_2.EDFS_NATS_SUBSCRIBE]);
|
|
1505
1831
|
}
|
|
1506
1832
|
}
|
|
1507
1833
|
getOperationTypeNodeForRootTypeName(parentTypeName) {
|
|
@@ -1510,11 +1836,11 @@ class NormalizationFactory {
|
|
|
1510
1836
|
return operationTypeNode;
|
|
1511
1837
|
}
|
|
1512
1838
|
switch (parentTypeName) {
|
|
1513
|
-
case
|
|
1839
|
+
case string_constants_2.MUTATION:
|
|
1514
1840
|
return graphql_1.OperationTypeNode.MUTATION;
|
|
1515
|
-
case
|
|
1841
|
+
case string_constants_2.QUERY:
|
|
1516
1842
|
return graphql_1.OperationTypeNode.QUERY;
|
|
1517
|
-
case
|
|
1843
|
+
case string_constants_2.SUBSCRIPTION:
|
|
1518
1844
|
return graphql_1.OperationTypeNode.SUBSCRIPTION;
|
|
1519
1845
|
default:
|
|
1520
1846
|
return;
|
|
@@ -1550,7 +1876,7 @@ class NormalizationFactory {
|
|
|
1550
1876
|
}
|
|
1551
1877
|
if (operationTypeNode === graphql_1.OperationTypeNode.MUTATION) {
|
|
1552
1878
|
const typeString = (0, merge_1.printTypeNode)(fieldData.type);
|
|
1553
|
-
if (typeString !==
|
|
1879
|
+
if (typeString !== string_constants_2.NON_NULLABLE_EDFS_PUBLISH_EVENT_RESULT) {
|
|
1554
1880
|
invalidResponseTypeNameByMutationPath.set(fieldPath, typeString);
|
|
1555
1881
|
}
|
|
1556
1882
|
continue;
|
|
@@ -1572,22 +1898,22 @@ class NormalizationFactory {
|
|
|
1572
1898
|
}
|
|
1573
1899
|
}
|
|
1574
1900
|
validateEventDrivenKeyDefinition(typeName, invalidKeyFieldSetsByEntityTypeName) {
|
|
1575
|
-
const
|
|
1576
|
-
if (!
|
|
1901
|
+
const keyFieldSetDataByFieldSet = this.keyFieldSetDatasByTypeName.get(typeName);
|
|
1902
|
+
if (!keyFieldSetDataByFieldSet) {
|
|
1577
1903
|
return;
|
|
1578
1904
|
}
|
|
1579
|
-
for (const [keyFieldSet, isUnresolvable] of
|
|
1905
|
+
for (const [keyFieldSet, { isUnresolvable }] of keyFieldSetDataByFieldSet) {
|
|
1580
1906
|
if (isUnresolvable) {
|
|
1581
1907
|
continue;
|
|
1582
1908
|
}
|
|
1583
|
-
(0,
|
|
1909
|
+
(0, utils_5.getValueOrDefault)(invalidKeyFieldSetsByEntityTypeName, typeName, () => []).push(keyFieldSet);
|
|
1584
1910
|
}
|
|
1585
1911
|
}
|
|
1586
1912
|
validateEventDrivenObjectFields(fieldDataByFieldName, keyFieldNames, nonExternalKeyFieldNameByFieldPath, nonKeyFieldNameByFieldPath) {
|
|
1587
1913
|
for (const [fieldName, fieldData] of fieldDataByFieldName) {
|
|
1588
1914
|
const fieldPath = `${fieldData.originalParentTypeName}.${fieldName}`;
|
|
1589
1915
|
if (keyFieldNames.has(fieldName)) {
|
|
1590
|
-
if (!fieldData.
|
|
1916
|
+
if (!fieldData.externalFieldDataBySubgraphName.get(this.subgraphName)?.isDefinedExternal) {
|
|
1591
1917
|
nonExternalKeyFieldNameByFieldPath.set(fieldPath, fieldName);
|
|
1592
1918
|
}
|
|
1593
1919
|
continue;
|
|
@@ -1596,7 +1922,7 @@ class NormalizationFactory {
|
|
|
1596
1922
|
}
|
|
1597
1923
|
}
|
|
1598
1924
|
isEdfsPublishResultValid() {
|
|
1599
|
-
const data = this.parentDefinitionDataByTypeName.get(
|
|
1925
|
+
const data = this.parentDefinitionDataByTypeName.get(string_constants_2.EDFS_PUBLISH_RESULT);
|
|
1600
1926
|
if (!data) {
|
|
1601
1927
|
return true;
|
|
1602
1928
|
}
|
|
@@ -1610,10 +1936,10 @@ class NormalizationFactory {
|
|
|
1610
1936
|
if (fieldData.argumentDataByArgumentName.size > 0) {
|
|
1611
1937
|
return false;
|
|
1612
1938
|
}
|
|
1613
|
-
if (fieldName !==
|
|
1939
|
+
if (fieldName !== string_constants_2.SUCCESS) {
|
|
1614
1940
|
return false;
|
|
1615
1941
|
}
|
|
1616
|
-
if ((0, merge_1.printTypeNode)(fieldData.type) !==
|
|
1942
|
+
if ((0, merge_1.printTypeNode)(fieldData.type) !== string_constants_2.NON_NULLABLE_BOOLEAN) {
|
|
1617
1943
|
return false;
|
|
1618
1944
|
}
|
|
1619
1945
|
}
|
|
@@ -1628,8 +1954,8 @@ class NormalizationFactory {
|
|
|
1628
1954
|
}
|
|
1629
1955
|
for (const [inputValueName, inputValueData] of streamConfigurationInputData.inputValueDataByValueName) {
|
|
1630
1956
|
switch (inputValueName) {
|
|
1631
|
-
case
|
|
1632
|
-
if ((0, merge_1.printTypeNode)(inputValueData.type) !==
|
|
1957
|
+
case string_constants_2.CONSUMER_INACTIVE_THRESHOLD: {
|
|
1958
|
+
if ((0, merge_1.printTypeNode)(inputValueData.type) !== string_constants_2.NON_NULLABLE_INT) {
|
|
1633
1959
|
return false;
|
|
1634
1960
|
}
|
|
1635
1961
|
if (!inputValueData.defaultValue ||
|
|
@@ -1639,10 +1965,10 @@ class NormalizationFactory {
|
|
|
1639
1965
|
}
|
|
1640
1966
|
break;
|
|
1641
1967
|
}
|
|
1642
|
-
case
|
|
1968
|
+
case string_constants_2.CONSUMER_NAME:
|
|
1643
1969
|
// intentional fallthrough
|
|
1644
|
-
case
|
|
1645
|
-
if ((0, merge_1.printTypeNode)(inputValueData.type) !==
|
|
1970
|
+
case string_constants_2.STREAM_NAME: {
|
|
1971
|
+
if ((0, merge_1.printTypeNode)(inputValueData.type) !== string_constants_2.NON_NULLABLE_STRING) {
|
|
1646
1972
|
return false;
|
|
1647
1973
|
}
|
|
1648
1974
|
break;
|
|
@@ -1666,7 +1992,7 @@ class NormalizationFactory {
|
|
|
1666
1992
|
const invalidObjectTypeNames = new Set();
|
|
1667
1993
|
for (const [typeName, data] of this.parentDefinitionDataByTypeName) {
|
|
1668
1994
|
// validate edfs__PublishResult and edfs__NatsStreamConfiguration separately
|
|
1669
|
-
if (typeName ===
|
|
1995
|
+
if (typeName === string_constants_2.EDFS_PUBLISH_RESULT || typeName === string_constants_2.EDFS_NATS_STREAM_CONFIGURATION) {
|
|
1670
1996
|
continue;
|
|
1671
1997
|
}
|
|
1672
1998
|
if (data.kind !== graphql_1.Kind.OBJECT_TYPE_DEFINITION) {
|
|
@@ -1687,18 +2013,18 @@ class NormalizationFactory {
|
|
|
1687
2013
|
if (!this.isEdfsPublishResultValid()) {
|
|
1688
2014
|
errorMessages.push(errors_1.invalidEdfsPublishResultObjectErrorMessage);
|
|
1689
2015
|
}
|
|
1690
|
-
if (this.edfsDirectiveReferences.has(
|
|
1691
|
-
const streamConfigurationInputData = this.parentDefinitionDataByTypeName.get(
|
|
2016
|
+
if (this.edfsDirectiveReferences.has(string_constants_2.EDFS_NATS_SUBSCRIBE)) {
|
|
2017
|
+
const streamConfigurationInputData = this.parentDefinitionDataByTypeName.get(string_constants_2.EDFS_NATS_STREAM_CONFIGURATION);
|
|
1692
2018
|
if (streamConfigurationInputData &&
|
|
1693
2019
|
this.usesEdfsNatsStreamConfiguration &&
|
|
1694
2020
|
!this.isNatsStreamConfigurationInputObjectValid(streamConfigurationInputData)) {
|
|
1695
2021
|
errorMessages.push(errors_1.invalidNatsStreamConfigurationDefinitionErrorMessage);
|
|
1696
2022
|
}
|
|
1697
2023
|
// always add the correct definition to the schema regardless
|
|
1698
|
-
this.parentDefinitionDataByTypeName.delete(
|
|
2024
|
+
this.parentDefinitionDataByTypeName.delete(string_constants_2.EDFS_NATS_STREAM_CONFIGURATION);
|
|
1699
2025
|
definitions.push(constants_1.EDFS_NATS_STREAM_CONFIGURATION_DEFINITION);
|
|
1700
2026
|
}
|
|
1701
|
-
if (this.referencedDirectiveNames.has(
|
|
2027
|
+
if (this.referencedDirectiveNames.has(string_constants_2.LINK)) {
|
|
1702
2028
|
definitions.push(constants_1.LINK_DEFINITION);
|
|
1703
2029
|
definitions.push(constants_1.LINK_IMPORT_DEFINITION);
|
|
1704
2030
|
definitions.push(constants_1.LINK_PURPOSE_DEFINITION);
|
|
@@ -1744,7 +2070,7 @@ class NormalizationFactory {
|
|
|
1744
2070
|
continue;
|
|
1745
2071
|
}
|
|
1746
2072
|
if (memberData.kind !== graphql_1.Kind.OBJECT_TYPE_DEFINITION) {
|
|
1747
|
-
invalidMembers.push(`"${memberName}", which is type "${(0,
|
|
2073
|
+
invalidMembers.push(`"${memberName}", which is type "${(0, utils_5.kindToTypeString)(memberData.kind)}"`);
|
|
1748
2074
|
}
|
|
1749
2075
|
}
|
|
1750
2076
|
if (invalidMembers.length > 0) {
|
|
@@ -1758,26 +2084,24 @@ class NormalizationFactory {
|
|
|
1758
2084
|
const unionTypeName = node.name.value;
|
|
1759
2085
|
for (const member of node.types) {
|
|
1760
2086
|
const memberTypeName = member.name.value;
|
|
1761
|
-
(0,
|
|
2087
|
+
(0, utils_5.getValueOrDefault)(this.concreteTypeNamesByAbstractTypeName, unionTypeName, () => new Set()).add(memberTypeName);
|
|
1762
2088
|
this.internalGraph.addEdge(this.internalGraph.addOrUpdateNode(unionTypeName, { isAbstract: true }), this.internalGraph.addOrUpdateNode(memberTypeName), memberTypeName, true);
|
|
1763
2089
|
}
|
|
1764
2090
|
}
|
|
1765
|
-
|
|
1766
|
-
const
|
|
1767
|
-
|
|
1768
|
-
if (keys) {
|
|
1769
|
-
configurationData.keys = keys;
|
|
1770
|
-
}
|
|
1771
|
-
}
|
|
1772
|
-
validateAndAddKeysToConfiguration() {
|
|
1773
|
-
for (const [parentTypeName, keyFieldSetData] of this.keyFieldSetDataByTypeName) {
|
|
1774
|
-
const parentData = this.parentDefinitionDataByTypeName.get(parentTypeName);
|
|
2091
|
+
addValidKeyFieldSetConfigurations() {
|
|
2092
|
+
for (const [entityTypeName, keyFieldSetDataByFieldSet] of this.keyFieldSetDatasByTypeName) {
|
|
2093
|
+
const parentData = this.parentDefinitionDataByTypeName.get(entityTypeName);
|
|
1775
2094
|
if (!parentData ||
|
|
1776
2095
|
(parentData.kind !== graphql_1.Kind.OBJECT_TYPE_DEFINITION && parentData.kind !== graphql_1.Kind.INTERFACE_TYPE_DEFINITION)) {
|
|
1777
|
-
this.errors.push((0, errors_1.
|
|
2096
|
+
this.errors.push((0, errors_1.undefinedCompositeOutputTypeError)(entityTypeName));
|
|
1778
2097
|
continue;
|
|
1779
2098
|
}
|
|
1780
|
-
|
|
2099
|
+
const typeName = (0, utils_4.getParentTypeName)(parentData);
|
|
2100
|
+
const configurationData = (0, utils_5.getValueOrDefault)(this.configurationDataByTypeName, typeName, () => (0, utils_6.newConfigurationData)(true, typeName));
|
|
2101
|
+
const keys = (0, utils_2.validateKeyFieldSets)(this, parentData, keyFieldSetDataByFieldSet, configurationData.fieldNames);
|
|
2102
|
+
if (keys) {
|
|
2103
|
+
configurationData.keys = keys;
|
|
2104
|
+
}
|
|
1781
2105
|
}
|
|
1782
2106
|
}
|
|
1783
2107
|
getValidFlattenedDirectiveArray(directivesByDirectiveName, directiveCoords) {
|
|
@@ -1788,7 +2112,7 @@ class NormalizationFactory {
|
|
|
1788
2112
|
continue;
|
|
1789
2113
|
}
|
|
1790
2114
|
if (!directiveDefinition.isRepeatable && directiveNodes.length > 1) {
|
|
1791
|
-
const handledDirectiveNames = (0,
|
|
2115
|
+
const handledDirectiveNames = (0, utils_5.getValueOrDefault)(this.invalidRepeatedDirectiveNameByCoords, directiveCoords, () => new Set());
|
|
1792
2116
|
if (!handledDirectiveNames.has(directiveName)) {
|
|
1793
2117
|
handledDirectiveNames.add(directiveName);
|
|
1794
2118
|
this.errors.push((0, errors_1.invalidDirectiveError)(directiveName, directiveCoords, '1st', [
|
|
@@ -1797,7 +2121,7 @@ class NormalizationFactory {
|
|
|
1797
2121
|
}
|
|
1798
2122
|
continue;
|
|
1799
2123
|
}
|
|
1800
|
-
if (directiveName !==
|
|
2124
|
+
if (directiveName !== string_constants_2.KEY) {
|
|
1801
2125
|
flattenedArray.push(...directiveNodes);
|
|
1802
2126
|
continue;
|
|
1803
2127
|
}
|
|
@@ -1859,6 +2183,179 @@ class NormalizationFactory {
|
|
|
1859
2183
|
unionDefinitionData.node.types = (0, utils_3.mapToArrayOfValues)(unionDefinitionData.memberByMemberTypeName);
|
|
1860
2184
|
return unionDefinitionData.node;
|
|
1861
2185
|
}
|
|
2186
|
+
evaluateExternalKeyFields() {
|
|
2187
|
+
const invalidTypeNames = [];
|
|
2188
|
+
for (const [entityTypeName, keyFieldSetDataByFieldSet] of this.keyFieldSetDatasByTypeName) {
|
|
2189
|
+
const entityParentData = this.parentDefinitionDataByTypeName.get(entityTypeName);
|
|
2190
|
+
// The parent data should always exist.
|
|
2191
|
+
if (!entityParentData ||
|
|
2192
|
+
(entityParentData.kind !== graphql_1.Kind.OBJECT_TYPE_DEFINITION &&
|
|
2193
|
+
entityParentData.kind !== graphql_1.Kind.INTERFACE_TYPE_DEFINITION)) {
|
|
2194
|
+
// If somehow the parent data does not exist, prevent the same error occurring by removing that type from the map.
|
|
2195
|
+
invalidTypeNames.push(entityTypeName);
|
|
2196
|
+
this.errors.push((0, errors_1.undefinedCompositeOutputTypeError)(entityTypeName));
|
|
2197
|
+
continue;
|
|
2198
|
+
}
|
|
2199
|
+
const nf = this;
|
|
2200
|
+
for (const keyFieldSetData of keyFieldSetDataByFieldSet.values()) {
|
|
2201
|
+
const parentDatas = [entityParentData];
|
|
2202
|
+
// Entity extension fields are effectively never @external, so propagate a warning.
|
|
2203
|
+
const externalExtensionFieldCoordsByRawFieldSet = new Map();
|
|
2204
|
+
let currentDepth = -1;
|
|
2205
|
+
let shouldDefineSelectionSet = true;
|
|
2206
|
+
(0, index_1.visit)(keyFieldSetData.documentNode, {
|
|
2207
|
+
Argument: {
|
|
2208
|
+
enter() {
|
|
2209
|
+
return index_1.BREAK;
|
|
2210
|
+
},
|
|
2211
|
+
},
|
|
2212
|
+
Field: {
|
|
2213
|
+
enter(node) {
|
|
2214
|
+
const parentData = parentDatas[currentDepth];
|
|
2215
|
+
const parentTypeName = parentData.name;
|
|
2216
|
+
// If a composite type was just visited, a selection set should have been entered
|
|
2217
|
+
if (shouldDefineSelectionSet) {
|
|
2218
|
+
return index_1.BREAK;
|
|
2219
|
+
}
|
|
2220
|
+
const fieldName = node.name.value;
|
|
2221
|
+
const fieldCoords = `${parentTypeName}.${fieldName}`;
|
|
2222
|
+
// If a field declared @external is a key field, it is valid use of @external.
|
|
2223
|
+
nf.unvalidatedExternalFieldCoords.delete(fieldCoords);
|
|
2224
|
+
const fieldData = parentData.fieldDataByFieldName.get(fieldName);
|
|
2225
|
+
// undefined if the field does not exist on the parent
|
|
2226
|
+
if (!fieldData || fieldData.argumentDataByArgumentName.size) {
|
|
2227
|
+
return index_1.BREAK;
|
|
2228
|
+
}
|
|
2229
|
+
// Fields that form part of an entity key are intrinsically shareable
|
|
2230
|
+
fieldData.isShareableBySubgraphName.set(nf.subgraphName, true);
|
|
2231
|
+
/* !!! IMPORTANT NOTE REGARDING INCONSISTENT APOLLO BEHAVIOUR !!!
|
|
2232
|
+
* V1 entities with "@extends" may define unique nested key fields as @external without restriction.
|
|
2233
|
+
* However, V1 entity extensions (with the "extend" keyword) cannot do this.
|
|
2234
|
+
* Instead, an error is returned stating that there must be a non-external definition of the field.
|
|
2235
|
+
* This inconsistency in behaviour appears to be a bug.
|
|
2236
|
+
* It doesn't make much sense to enforce "origin fields" only sometimes (or ever, honestly).
|
|
2237
|
+
* Consequently, a decision was made not ever to enforce meaningless origin fields for extensions.
|
|
2238
|
+
*
|
|
2239
|
+
* In the event the nested key field is not unique, the error may propagate as a field resolvability
|
|
2240
|
+
* error, e.g., unable to use the nested @external key field to satisfy a field set in another subgraph.
|
|
2241
|
+
*
|
|
2242
|
+
* In addition, the nested key field of a V2 entity extension (either "@extends" or "extend" keyword)
|
|
2243
|
+
* are considered unconditionally provided regardless of the presence of "@external".
|
|
2244
|
+
*
|
|
2245
|
+
* However, if the subgraph is an EDG, the @external state should be kept regardless of extension.
|
|
2246
|
+
* */
|
|
2247
|
+
const externalFieldData = fieldData.externalFieldDataBySubgraphName.get(nf.subgraphName);
|
|
2248
|
+
if (nf.edfsDirectiveReferences.size < 1 &&
|
|
2249
|
+
externalFieldData &&
|
|
2250
|
+
externalFieldData.isDefinedExternal &&
|
|
2251
|
+
!externalFieldData.isUnconditionallyProvided) {
|
|
2252
|
+
/*
|
|
2253
|
+
* The key field is unconditionally provided if all the following are true:
|
|
2254
|
+
* 1. The root entity is an extension type.
|
|
2255
|
+
* 2. The field is also a key field for the parent entity.
|
|
2256
|
+
*/
|
|
2257
|
+
if (entityParentData.extensionType !== types_1.ExtensionType.NONE) {
|
|
2258
|
+
externalFieldData.isUnconditionallyProvided = true;
|
|
2259
|
+
(0, utils_5.getValueOrDefault)(externalExtensionFieldCoordsByRawFieldSet, keyFieldSetData.rawFieldSet, () => new Set()).add(fieldCoords);
|
|
2260
|
+
}
|
|
2261
|
+
}
|
|
2262
|
+
(0, utils_5.getValueOrDefault)(nf.keyFieldNamesByParentTypeName, parentTypeName, () => new Set()).add(fieldName);
|
|
2263
|
+
const namedTypeName = (0, ast_1.getTypeNodeNamedTypeName)(fieldData.node.type);
|
|
2264
|
+
// The base scalars are not in the parents map
|
|
2265
|
+
if (constants_1.BASE_SCALARS.has(namedTypeName)) {
|
|
2266
|
+
return;
|
|
2267
|
+
}
|
|
2268
|
+
// The child could itself be a parent
|
|
2269
|
+
const namedTypeData = nf.parentDefinitionDataByTypeName.get(namedTypeName);
|
|
2270
|
+
if (!namedTypeData) {
|
|
2271
|
+
return index_1.BREAK;
|
|
2272
|
+
}
|
|
2273
|
+
if (namedTypeData.kind === graphql_1.Kind.OBJECT_TYPE_DEFINITION) {
|
|
2274
|
+
shouldDefineSelectionSet = true;
|
|
2275
|
+
parentDatas.push(namedTypeData);
|
|
2276
|
+
return;
|
|
2277
|
+
}
|
|
2278
|
+
// interfaces and unions are invalid in a key directive
|
|
2279
|
+
if ((0, utils_1.isKindAbstract)(namedTypeData.kind)) {
|
|
2280
|
+
return index_1.BREAK;
|
|
2281
|
+
}
|
|
2282
|
+
},
|
|
2283
|
+
},
|
|
2284
|
+
InlineFragment: {
|
|
2285
|
+
enter() {
|
|
2286
|
+
return index_1.BREAK;
|
|
2287
|
+
},
|
|
2288
|
+
},
|
|
2289
|
+
SelectionSet: {
|
|
2290
|
+
enter() {
|
|
2291
|
+
if (!shouldDefineSelectionSet) {
|
|
2292
|
+
return index_1.BREAK;
|
|
2293
|
+
}
|
|
2294
|
+
currentDepth += 1;
|
|
2295
|
+
shouldDefineSelectionSet = false;
|
|
2296
|
+
if (currentDepth < 0 || currentDepth >= parentDatas.length) {
|
|
2297
|
+
return index_1.BREAK;
|
|
2298
|
+
}
|
|
2299
|
+
},
|
|
2300
|
+
leave() {
|
|
2301
|
+
if (shouldDefineSelectionSet) {
|
|
2302
|
+
shouldDefineSelectionSet = false;
|
|
2303
|
+
}
|
|
2304
|
+
// Empty selection sets would be a parse error, so it is unnecessary to handle them
|
|
2305
|
+
currentDepth -= 1;
|
|
2306
|
+
parentDatas.pop();
|
|
2307
|
+
},
|
|
2308
|
+
},
|
|
2309
|
+
});
|
|
2310
|
+
if (externalExtensionFieldCoordsByRawFieldSet.size < 1) {
|
|
2311
|
+
continue;
|
|
2312
|
+
}
|
|
2313
|
+
for (const [rawFieldSet, fieldCoords] of externalExtensionFieldCoordsByRawFieldSet) {
|
|
2314
|
+
this.warnings.push((0, warnings_1.externalEntityExtensionKeyFieldWarning)(entityParentData.name, rawFieldSet, [...fieldCoords], this.subgraphName));
|
|
2315
|
+
}
|
|
2316
|
+
}
|
|
2317
|
+
}
|
|
2318
|
+
for (const invalidTypeName of invalidTypeNames) {
|
|
2319
|
+
this.keyFieldSetDatasByTypeName.delete(invalidTypeName);
|
|
2320
|
+
}
|
|
2321
|
+
}
|
|
2322
|
+
addValidConditionalFieldSetConfigurations() {
|
|
2323
|
+
for (const [typeName, fieldSetData] of this.fieldSetDataByTypeName) {
|
|
2324
|
+
const parentData = this.parentDefinitionDataByTypeName.get(typeName);
|
|
2325
|
+
if (!parentData ||
|
|
2326
|
+
(parentData.kind !== graphql_1.Kind.OBJECT_TYPE_DEFINITION && parentData.kind !== graphql_1.Kind.INTERFACE_TYPE_DEFINITION)) {
|
|
2327
|
+
this.errors.push((0, errors_1.undefinedCompositeOutputTypeError)(typeName));
|
|
2328
|
+
continue;
|
|
2329
|
+
}
|
|
2330
|
+
const parentTypeName = (0, utils_4.getParentTypeName)(parentData);
|
|
2331
|
+
const configurationData = (0, utils_5.getValueOrDefault)(this.configurationDataByTypeName, parentTypeName, () => (0, utils_6.newConfigurationData)(false, parentTypeName));
|
|
2332
|
+
const provides = this.validateProvidesOrRequires(parentData, fieldSetData.provides, true);
|
|
2333
|
+
if (provides) {
|
|
2334
|
+
configurationData.provides = provides;
|
|
2335
|
+
}
|
|
2336
|
+
const requires = this.validateProvidesOrRequires(parentData, fieldSetData.requires, false);
|
|
2337
|
+
if (requires) {
|
|
2338
|
+
configurationData.requires = requires;
|
|
2339
|
+
}
|
|
2340
|
+
}
|
|
2341
|
+
}
|
|
2342
|
+
addFieldNamesToConfigurationData(fieldDataByFieldName, configurationData) {
|
|
2343
|
+
const externalFieldNames = new Set();
|
|
2344
|
+
for (const [fieldName, fieldData] of fieldDataByFieldName) {
|
|
2345
|
+
const externalFieldData = fieldData.externalFieldDataBySubgraphName.get(this.subgraphName);
|
|
2346
|
+
if (!externalFieldData || externalFieldData.isUnconditionallyProvided) {
|
|
2347
|
+
configurationData.fieldNames.add(fieldName);
|
|
2348
|
+
continue;
|
|
2349
|
+
}
|
|
2350
|
+
externalFieldNames.add(fieldName);
|
|
2351
|
+
if (this.edfsDirectiveReferences.size > 0) {
|
|
2352
|
+
configurationData.fieldNames.add(fieldName);
|
|
2353
|
+
}
|
|
2354
|
+
}
|
|
2355
|
+
if (externalFieldNames.size > 0) {
|
|
2356
|
+
configurationData.externalFieldNames = externalFieldNames;
|
|
2357
|
+
}
|
|
2358
|
+
}
|
|
1862
2359
|
normalize(document) {
|
|
1863
2360
|
/* factory.allDirectiveDefinitions is initialized with v1 directive definitions, and v2 definitions are only added
|
|
1864
2361
|
after the visitor has visited the entire schema and the subgraph is known to be a V2 graph. Consequently,
|
|
@@ -1866,7 +2363,7 @@ class NormalizationFactory {
|
|
|
1866
2363
|
// Collect any renamed root types
|
|
1867
2364
|
(0, walkers_1.upsertDirectiveSchemaAndEntityDefinitions)(this, document);
|
|
1868
2365
|
(0, walkers_1.upsertParentsAndChildren)(this, document);
|
|
1869
|
-
this.validateDirectives(this.schemaData,
|
|
2366
|
+
this.validateDirectives(this.schemaData, string_constants_2.SCHEMA);
|
|
1870
2367
|
for (const [parentTypeName, parentData] of this.parentDefinitionDataByTypeName) {
|
|
1871
2368
|
this.validateDirectives(parentData, parentTypeName);
|
|
1872
2369
|
}
|
|
@@ -1878,7 +2375,7 @@ class NormalizationFactory {
|
|
|
1878
2375
|
}
|
|
1879
2376
|
const concreteTypeNames = this.concreteTypeNamesByAbstractTypeName.get(interfaceTypeName);
|
|
1880
2377
|
for (const concreteTypeName of concreteTypeNames || []) {
|
|
1881
|
-
const concreteAuthorizationData = (0,
|
|
2378
|
+
const concreteAuthorizationData = (0, utils_5.getValueOrDefault)(this.authorizationDataByParentTypeName, concreteTypeName, () => (0, utils_3.newAuthorizationData)(concreteTypeName));
|
|
1882
2379
|
for (const [fieldName, interfaceFieldAuthorizationData,] of interfaceAuthorizationData.fieldAuthorizationDataByFieldName) {
|
|
1883
2380
|
if (!(0, utils_3.upsertFieldAuthorizationData)(concreteAuthorizationData.fieldAuthorizationDataByFieldName, interfaceFieldAuthorizationData)) {
|
|
1884
2381
|
this.invalidOrScopesHostPaths.add(`${concreteTypeName}.${fieldName}`);
|
|
@@ -1923,16 +2420,16 @@ class NormalizationFactory {
|
|
|
1923
2420
|
definitions.push(directiveDefinition);
|
|
1924
2421
|
}
|
|
1925
2422
|
// subscriptionFilter is temporarily valid only in an EDG
|
|
1926
|
-
if (this.edfsDirectiveReferences.size > 0 && this.referencedDirectiveNames.has(
|
|
2423
|
+
if (this.edfsDirectiveReferences.size > 0 && this.referencedDirectiveNames.has(string_constants_2.SUBSCRIPTION_FILTER)) {
|
|
1927
2424
|
definitions.push(constants_1.SUBSCRIPTION_FILTER_DEFINITION);
|
|
1928
2425
|
definitions.push(constants_1.SUBSCRIPTION_FILTER_CONDITION_DEFINITION);
|
|
1929
2426
|
definitions.push(constants_1.SUBSCRIPTION_FIELD_CONDITION_DEFINITION);
|
|
1930
2427
|
definitions.push(constants_1.SUBSCRIPTION_FILTER_VALUE_DEFINITION);
|
|
1931
2428
|
}
|
|
1932
|
-
if (this.referencedDirectiveNames.has(
|
|
2429
|
+
if (this.referencedDirectiveNames.has(string_constants_2.CONFIGURE_DESCRIPTION)) {
|
|
1933
2430
|
definitions.push(constants_1.CONFIGURE_DESCRIPTION_DEFINITION);
|
|
1934
2431
|
}
|
|
1935
|
-
if (this.referencedDirectiveNames.has(
|
|
2432
|
+
if (this.referencedDirectiveNames.has(string_constants_2.CONFIGURE_CHILD_DESCRIPTIONS)) {
|
|
1936
2433
|
definitions.push(constants_1.CONFIGURE_CHILD_DESCRIPTIONS_DEFINITION);
|
|
1937
2434
|
}
|
|
1938
2435
|
for (const directiveDefinition of this.customDirectiveDefinitions.values()) {
|
|
@@ -1947,9 +2444,11 @@ class NormalizationFactory {
|
|
|
1947
2444
|
* */
|
|
1948
2445
|
for (const data of this.invalidConfigureDescriptionNodeDatas) {
|
|
1949
2446
|
if (!data.description) {
|
|
1950
|
-
this.errors.push((0, errors_1.configureDescriptionNoDescriptionError)((0,
|
|
2447
|
+
this.errors.push((0, errors_1.configureDescriptionNoDescriptionError)((0, utils_5.kindToTypeString)(data.kind), data.name));
|
|
1951
2448
|
}
|
|
1952
2449
|
}
|
|
2450
|
+
// Check all key field sets for @external fields to assess whether they are conditional
|
|
2451
|
+
this.evaluateExternalKeyFields();
|
|
1953
2452
|
for (const [parentTypeName, parentDefinitionData] of this.parentDefinitionDataByTypeName) {
|
|
1954
2453
|
switch (parentDefinitionData.kind) {
|
|
1955
2454
|
case graphql_1.Kind.ENUM_TYPE_DEFINITION:
|
|
@@ -1973,16 +2472,20 @@ class NormalizationFactory {
|
|
|
1973
2472
|
const isEntity = this.entityDataByTypeName.has(parentTypeName);
|
|
1974
2473
|
const operationTypeNode = this.operationTypeNodeByTypeName.get(parentTypeName);
|
|
1975
2474
|
const isObject = parentDefinitionData.kind === graphql_1.Kind.OBJECT_TYPE_DEFINITION;
|
|
2475
|
+
if (this.isSubgraphVersionTwo && parentDefinitionData.extensionType === types_1.ExtensionType.EXTENDS) {
|
|
2476
|
+
// @extends is essentially ignored in V2. It was only propagated to handle @external key fields.
|
|
2477
|
+
parentDefinitionData.extensionType = types_1.ExtensionType.NONE;
|
|
2478
|
+
}
|
|
1976
2479
|
if (operationTypeNode) {
|
|
1977
|
-
parentDefinitionData.fieldDataByFieldName.delete(
|
|
1978
|
-
parentDefinitionData.fieldDataByFieldName.delete(
|
|
2480
|
+
parentDefinitionData.fieldDataByFieldName.delete(string_constants_2.SERVICE_FIELD);
|
|
2481
|
+
parentDefinitionData.fieldDataByFieldName.delete(string_constants_2.ENTITIES_FIELD);
|
|
1979
2482
|
}
|
|
1980
2483
|
(0, utils_4.removeIgnoredDirectives)(parentDefinitionData);
|
|
1981
2484
|
(0, utils_4.removeInheritableDirectivesFromObjectParent)(parentDefinitionData);
|
|
1982
2485
|
if (this.parentsWithChildArguments.has(parentTypeName) || !isObject) {
|
|
1983
2486
|
const externalInterfaceFieldNames = [];
|
|
1984
2487
|
for (const [fieldName, fieldData] of parentDefinitionData.fieldDataByFieldName) {
|
|
1985
|
-
if (!isObject && fieldData.
|
|
2488
|
+
if (!isObject && fieldData.externalFieldDataBySubgraphName.get(this.subgraphName)?.isDefinedExternal) {
|
|
1986
2489
|
externalInterfaceFieldNames.push(fieldName);
|
|
1987
2490
|
}
|
|
1988
2491
|
// Arguments can only be fully validated once all parents types are known
|
|
@@ -1995,18 +2498,15 @@ class NormalizationFactory {
|
|
|
1995
2498
|
: this.warnings.push((0, warnings_1.externalInterfaceFieldsWarning)(this.subgraphName, parentTypeName, externalInterfaceFieldNames));
|
|
1996
2499
|
}
|
|
1997
2500
|
}
|
|
1998
|
-
const newParentTypeName =
|
|
1999
|
-
|
|
2000
|
-
: parentTypeName;
|
|
2001
|
-
const configurationData = {
|
|
2002
|
-
fieldNames: new Set(),
|
|
2003
|
-
isRootNode: isEntity,
|
|
2004
|
-
typeName: newParentTypeName,
|
|
2005
|
-
};
|
|
2501
|
+
const newParentTypeName = (0, utils_4.getParentTypeName)(parentDefinitionData);
|
|
2502
|
+
const configurationData = (0, utils_5.getValueOrDefault)(this.configurationDataByTypeName, newParentTypeName, () => (0, utils_6.newConfigurationData)(isEntity, parentTypeName));
|
|
2006
2503
|
const entityInterfaceData = this.entityInterfaceDataByTypeName.get(parentTypeName);
|
|
2007
2504
|
if (entityInterfaceData) {
|
|
2008
2505
|
entityInterfaceData.fieldDatas = (0, utils_3.fieldDatasToSimpleFieldDatas)(parentDefinitionData.fieldDataByFieldName.values());
|
|
2009
|
-
|
|
2506
|
+
const concreteTypeNames = this.concreteTypeNamesByAbstractTypeName.get(parentTypeName);
|
|
2507
|
+
if (concreteTypeNames) {
|
|
2508
|
+
(0, utils_5.addIterableValuesToSet)(concreteTypeNames, entityInterfaceData.concreteTypeNames);
|
|
2509
|
+
}
|
|
2010
2510
|
configurationData.isInterfaceObject = entityInterfaceData.isInterfaceObject;
|
|
2011
2511
|
configurationData.entityInterfaceConcreteTypeNames = entityInterfaceData.concreteTypeNames;
|
|
2012
2512
|
}
|
|
@@ -2014,17 +2514,16 @@ class NormalizationFactory {
|
|
|
2014
2514
|
if (events) {
|
|
2015
2515
|
configurationData.events = events;
|
|
2016
2516
|
}
|
|
2017
|
-
this.
|
|
2018
|
-
(0, utils_2.addFieldNamesToConfigurationData)(parentDefinitionData.fieldDataByFieldName, configurationData);
|
|
2517
|
+
this.addFieldNamesToConfigurationData(parentDefinitionData.fieldDataByFieldName, configurationData);
|
|
2019
2518
|
this.validateInterfaceImplementations(parentDefinitionData);
|
|
2020
2519
|
definitions.push(this.getCompositeOutputNodeByData(parentDefinitionData));
|
|
2021
2520
|
// interfaces and objects must define at least one field
|
|
2022
2521
|
if (parentDefinitionData.fieldDataByFieldName.size < 1 && !(0, utils_2.isNodeQuery)(parentTypeName, operationTypeNode)) {
|
|
2023
|
-
this.errors.push((0, errors_1.noFieldDefinitionsError)((0,
|
|
2522
|
+
this.errors.push((0, errors_1.noFieldDefinitionsError)((0, utils_5.kindToTypeString)(parentDefinitionData.kind), parentTypeName));
|
|
2024
2523
|
}
|
|
2025
2524
|
break;
|
|
2026
2525
|
case graphql_1.Kind.SCALAR_TYPE_DEFINITION:
|
|
2027
|
-
if (parentDefinitionData.extensionType ===
|
|
2526
|
+
if (parentDefinitionData.extensionType === types_1.ExtensionType.REAL) {
|
|
2028
2527
|
this.errors.push((0, errors_1.noBaseScalarDefinitionError)(parentTypeName));
|
|
2029
2528
|
break;
|
|
2030
2529
|
}
|
|
@@ -2039,10 +2538,14 @@ class NormalizationFactory {
|
|
|
2039
2538
|
throw (0, errors_1.unexpectedKindFatalError)(parentTypeName);
|
|
2040
2539
|
}
|
|
2041
2540
|
}
|
|
2541
|
+
// this is where @provides and @requires configurations are added to the ConfigurationData
|
|
2542
|
+
this.addValidConditionalFieldSetConfigurations();
|
|
2543
|
+
// this is where @key configurations are added to the ConfigurationData
|
|
2544
|
+
this.addValidKeyFieldSetConfigurations();
|
|
2042
2545
|
// Check that explicitly defined operations types are valid objects and that their fields are also valid
|
|
2043
2546
|
for (const operationType of Object.values(graphql_1.OperationTypeNode)) {
|
|
2044
2547
|
const operationTypeNode = this.schemaData.operationTypes.get(operationType);
|
|
2045
|
-
const defaultTypeName = (0,
|
|
2548
|
+
const defaultTypeName = (0, utils_5.getOrThrowError)(utils_1.operationTypeNodeToDefaultType, operationType, string_constants_2.OPERATION_TO_DEFAULT);
|
|
2046
2549
|
// If an operation type name was not declared, use the default
|
|
2047
2550
|
const operationTypeName = operationTypeNode ? (0, ast_1.getTypeNodeNamedTypeName)(operationTypeNode.type) : defaultTypeName;
|
|
2048
2551
|
// If a custom type is used, the default type should not be defined
|
|
@@ -2064,7 +2567,7 @@ class NormalizationFactory {
|
|
|
2064
2567
|
if (!objectData) {
|
|
2065
2568
|
continue;
|
|
2066
2569
|
}
|
|
2067
|
-
const rootNode = this.
|
|
2570
|
+
const rootNode = this.configurationDataByTypeName.get(defaultTypeName);
|
|
2068
2571
|
if (rootNode) {
|
|
2069
2572
|
rootNode.isRootNode = true;
|
|
2070
2573
|
rootNode.typeName = defaultTypeName;
|
|
@@ -2098,17 +2601,6 @@ class NormalizationFactory {
|
|
|
2098
2601
|
this.errors.push((0, errors_1.undefinedTypeError)(referencedTypeName));
|
|
2099
2602
|
}
|
|
2100
2603
|
}
|
|
2101
|
-
this.validateAndAddKeysToConfiguration();
|
|
2102
|
-
for (const [parentTypeName, fieldSetData] of this.fieldSetDataByTypeName) {
|
|
2103
|
-
const parentData = this.parentDefinitionDataByTypeName.get(parentTypeName);
|
|
2104
|
-
if (!parentData ||
|
|
2105
|
-
(parentData.kind !== graphql_1.Kind.OBJECT_TYPE_DEFINITION && parentData.kind !== graphql_1.Kind.INTERFACE_TYPE_DEFINITION)) {
|
|
2106
|
-
this.errors.push((0, errors_1.undefinedObjectLikeParentError)(parentTypeName));
|
|
2107
|
-
continue;
|
|
2108
|
-
}
|
|
2109
|
-
// this is where keys, provides, and requires are added to the ConfigurationData
|
|
2110
|
-
(0, utils_2.validateAndAddConditionalFieldSetsToConfiguration)(this, parentData, fieldSetData);
|
|
2111
|
-
}
|
|
2112
2604
|
const persistedDirectiveDefinitionDataByDirectiveName = new Map();
|
|
2113
2605
|
for (const directiveDefinitionNode of this.directiveDefinitionByDirectiveName.values()) {
|
|
2114
2606
|
// TODO @composeDirective directives would also be handled here
|
|
@@ -2131,34 +2623,33 @@ class NormalizationFactory {
|
|
|
2131
2623
|
}
|
|
2132
2624
|
}
|
|
2133
2625
|
if (this.errors.length > 0) {
|
|
2134
|
-
return { errors: this.errors, warnings: this.warnings };
|
|
2626
|
+
return { success: false, errors: this.errors, warnings: this.warnings };
|
|
2135
2627
|
}
|
|
2136
2628
|
const newAST = {
|
|
2137
2629
|
kind: graphql_1.Kind.DOCUMENT,
|
|
2138
2630
|
definitions,
|
|
2139
2631
|
};
|
|
2140
2632
|
return {
|
|
2141
|
-
|
|
2142
|
-
|
|
2143
|
-
|
|
2144
|
-
|
|
2145
|
-
|
|
2146
|
-
|
|
2147
|
-
|
|
2148
|
-
|
|
2149
|
-
|
|
2150
|
-
|
|
2151
|
-
|
|
2152
|
-
|
|
2153
|
-
|
|
2154
|
-
|
|
2155
|
-
|
|
2156
|
-
|
|
2157
|
-
|
|
2158
|
-
|
|
2159
|
-
|
|
2160
|
-
|
|
2161
|
-
},
|
|
2633
|
+
authorizationDataByParentTypeName: this.authorizationDataByParentTypeName,
|
|
2634
|
+
// configurationDataMap is map of ConfigurationData per type name.
|
|
2635
|
+
// It is an Intermediate configuration object that will be converted to an engine configuration in the router
|
|
2636
|
+
concreteTypeNamesByAbstractTypeName: this.concreteTypeNamesByAbstractTypeName,
|
|
2637
|
+
conditionalFieldDataByCoordinates: this.conditionalFieldDataByCoords,
|
|
2638
|
+
configurationDataByTypeName: this.configurationDataByTypeName,
|
|
2639
|
+
entityDataByTypeName: this.entityDataByTypeName,
|
|
2640
|
+
entityInterfaces: this.entityInterfaceDataByTypeName,
|
|
2641
|
+
isEventDrivenGraph: this.isSubgraphEventDrivenGraph,
|
|
2642
|
+
isVersionTwo: this.isSubgraphVersionTwo,
|
|
2643
|
+
keyFieldNamesByParentTypeName: this.keyFieldNamesByParentTypeName,
|
|
2644
|
+
operationTypes: this.operationTypeNodeByTypeName,
|
|
2645
|
+
originalTypeNameByRenamedTypeName: this.originalTypeNameByRenamedTypeName,
|
|
2646
|
+
overridesByTargetSubgraphName: this.overridesByTargetSubgraphName,
|
|
2647
|
+
parentDefinitionDataByTypeName: this.parentDefinitionDataByTypeName,
|
|
2648
|
+
persistedDirectiveDefinitionDataByDirectiveName,
|
|
2649
|
+
subgraphAST: newAST,
|
|
2650
|
+
subgraphString: (0, graphql_1.print)(newAST),
|
|
2651
|
+
schema: (0, buildASTSchema_1.buildASTSchema)(newAST, { assumeValid: true, assumeValidSDL: true }),
|
|
2652
|
+
success: true,
|
|
2162
2653
|
warnings: this.warnings,
|
|
2163
2654
|
};
|
|
2164
2655
|
}
|
|
@@ -2192,12 +2683,12 @@ function batchNormalize(subgraphs) {
|
|
|
2192
2683
|
if (!subgraph.name) {
|
|
2193
2684
|
invalidNameErrorMessages.push((0, errors_1.invalidSubgraphNameErrorMessage)(i, subgraphName));
|
|
2194
2685
|
}
|
|
2195
|
-
const
|
|
2196
|
-
if (
|
|
2197
|
-
warnings.push(...
|
|
2686
|
+
const normalizationResult = normalizeSubgraph(subgraph.definitions, subgraph.name, internalGraph);
|
|
2687
|
+
if (normalizationResult.warnings.length > 0) {
|
|
2688
|
+
warnings.push(...normalizationResult.warnings);
|
|
2198
2689
|
}
|
|
2199
|
-
if (
|
|
2200
|
-
validationErrors.push((0, errors_1.subgraphValidationError)(subgraphName, errors));
|
|
2690
|
+
if (!normalizationResult.success) {
|
|
2691
|
+
validationErrors.push((0, errors_1.subgraphValidationError)(subgraphName, normalizationResult.errors));
|
|
2201
2692
|
continue;
|
|
2202
2693
|
}
|
|
2203
2694
|
if (!normalizationResult) {
|
|
@@ -2214,10 +2705,19 @@ function batchNormalize(subgraphs) {
|
|
|
2214
2705
|
concreteTypeNamesByAbstractTypeName.set(abstractTypeName, new Set(incomingConcreteTypeNames));
|
|
2215
2706
|
continue;
|
|
2216
2707
|
}
|
|
2217
|
-
(0,
|
|
2708
|
+
(0, utils_5.addIterableValuesToSet)(incomingConcreteTypeNames, existingConcreteTypeNames);
|
|
2218
2709
|
}
|
|
2219
|
-
for (const entityData of normalizationResult.entityDataByTypeName
|
|
2220
|
-
|
|
2710
|
+
for (const [typeName, entityData] of normalizationResult.entityDataByTypeName) {
|
|
2711
|
+
const keyFieldSetDataByFieldSet = entityData.keyFieldSetDatasBySubgraphName.get(subgraphName);
|
|
2712
|
+
if (!keyFieldSetDataByFieldSet) {
|
|
2713
|
+
continue;
|
|
2714
|
+
}
|
|
2715
|
+
(0, utils_3.upsertEntityData)({
|
|
2716
|
+
entityDataByTypeName,
|
|
2717
|
+
keyFieldSetDataByFieldSet,
|
|
2718
|
+
typeName,
|
|
2719
|
+
subgraphName,
|
|
2720
|
+
});
|
|
2221
2721
|
}
|
|
2222
2722
|
if (subgraph.name) {
|
|
2223
2723
|
internalSubgraphBySubgraphName.set(subgraphName, {
|
|
@@ -2249,9 +2749,9 @@ function batchNormalize(subgraphs) {
|
|
|
2249
2749
|
warnings.push((0, warnings_1.invalidOverrideTargetSubgraphNameWarning)(targetSubgraphName, originalParentTypeName, [...fieldNames], subgraph.name));
|
|
2250
2750
|
}
|
|
2251
2751
|
else {
|
|
2252
|
-
const overridesData = (0,
|
|
2253
|
-
const existingFieldNames = (0,
|
|
2254
|
-
(0,
|
|
2752
|
+
const overridesData = (0, utils_5.getValueOrDefault)(allOverridesByTargetSubgraphName, targetSubgraphName, () => new Map());
|
|
2753
|
+
const existingFieldNames = (0, utils_5.getValueOrDefault)(overridesData, parentTypeName, () => new Set(fieldNames));
|
|
2754
|
+
(0, utils_5.addIterableValuesToSet)(fieldNames, existingFieldNames);
|
|
2255
2755
|
}
|
|
2256
2756
|
for (const fieldName of fieldNames) {
|
|
2257
2757
|
const fieldPath = `${originalParentTypeName}.${fieldName}`;
|
|
@@ -2276,7 +2776,7 @@ function batchNormalize(subgraphs) {
|
|
|
2276
2776
|
if (duplicateOverriddenFieldPaths.size > 0) {
|
|
2277
2777
|
const duplicateOverriddenFieldErrorMessages = [];
|
|
2278
2778
|
for (const fieldPath of duplicateOverriddenFieldPaths) {
|
|
2279
|
-
const sourceSubgraphNames = (0,
|
|
2779
|
+
const sourceSubgraphNames = (0, utils_5.getOrThrowError)(overrideSourceSubgraphNamesByFieldPath, fieldPath, 'overrideSourceSubgraphNamesByFieldPath');
|
|
2280
2780
|
duplicateOverriddenFieldErrorMessages.push((0, errors_1.duplicateOverriddenFieldErrorMessage)(fieldPath, sourceSubgraphNames));
|
|
2281
2781
|
}
|
|
2282
2782
|
allErrors.push((0, errors_1.duplicateOverriddenFieldsError)(duplicateOverriddenFieldErrorMessages));
|
|
@@ -2284,17 +2784,13 @@ function batchNormalize(subgraphs) {
|
|
|
2284
2784
|
allErrors.push(...validationErrors);
|
|
2285
2785
|
if (allErrors.length > 0) {
|
|
2286
2786
|
return {
|
|
2287
|
-
authorizationDataByParentTypeName,
|
|
2288
|
-
concreteTypeNamesByAbstractTypeName,
|
|
2289
|
-
entityDataByTypeName,
|
|
2290
2787
|
errors: allErrors,
|
|
2291
|
-
|
|
2292
|
-
internalGraph,
|
|
2788
|
+
success: false,
|
|
2293
2789
|
warnings,
|
|
2294
2790
|
};
|
|
2295
2791
|
}
|
|
2296
2792
|
for (const [targetSubgraphName, overridesData] of allOverridesByTargetSubgraphName) {
|
|
2297
|
-
const internalSubgraph = (0,
|
|
2793
|
+
const internalSubgraph = (0, utils_5.getOrThrowError)(internalSubgraphBySubgraphName, targetSubgraphName, 'internalSubgraphBySubgraphName');
|
|
2298
2794
|
internalSubgraph.overriddenFieldNamesByParentTypeName = overridesData;
|
|
2299
2795
|
for (const [parentTypeName, fieldNames] of overridesData) {
|
|
2300
2796
|
const configurationData = internalSubgraph.configurationDataByTypeName.get(parentTypeName);
|
|
@@ -2313,6 +2809,7 @@ function batchNormalize(subgraphs) {
|
|
|
2313
2809
|
entityDataByTypeName,
|
|
2314
2810
|
internalSubgraphBySubgraphName: internalSubgraphBySubgraphName,
|
|
2315
2811
|
internalGraph,
|
|
2812
|
+
success: true,
|
|
2316
2813
|
warnings,
|
|
2317
2814
|
};
|
|
2318
2815
|
}
|