@wundergraph/composition 0.36.1 → 0.37.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/ast/utils.d.ts +0 -2
- package/dist/ast/utils.js +0 -31
- package/dist/ast/utils.js.map +1 -1
- package/dist/errors/errors.d.ts +3 -3
- package/dist/errors/errors.js +11 -7
- package/dist/errors/errors.js.map +1 -1
- package/dist/federation/federation.d.ts +6 -0
- package/dist/federation/federation.js +30 -0
- package/dist/federation/federation.js.map +1 -0
- package/dist/federation/types.d.ts +44 -0
- package/dist/federation/types.js +3 -0
- package/dist/federation/types.js.map +1 -0
- package/dist/index.d.ts +21 -13
- package/dist/index.js +22 -13
- package/dist/index.js.map +1 -1
- package/dist/normalization/normalization.d.ts +6 -0
- package/dist/normalization/normalization.js +21 -0
- package/dist/normalization/normalization.js.map +1 -0
- package/dist/normalization/types.d.ts +48 -0
- package/dist/normalization/types.js +3 -0
- package/dist/normalization/types.js.map +1 -0
- package/dist/resolvability-graph/graph.d.ts +2 -2
- package/dist/resolvability-graph/graph.js +21 -21
- package/dist/resolvability-graph/graph.js.map +1 -1
- package/dist/resolvability-graph/utils.js +2 -2
- package/dist/resolvability-graph/utils.js.map +1 -1
- package/dist/router-compatibility-version/router-compatibility-version.d.ts +4 -0
- package/dist/router-compatibility-version/router-compatibility-version.js +7 -0
- package/dist/router-compatibility-version/router-compatibility-version.js.map +1 -0
- package/dist/schema-building/ast.js.map +1 -1
- package/dist/schema-building/{type-definition-data.d.ts → types.d.ts} +34 -3
- package/dist/schema-building/{type-definition-data.js → types.js} +1 -1
- package/dist/schema-building/types.js.map +1 -0
- package/dist/schema-building/utils.d.ts +2 -7
- package/dist/schema-building/utils.js +5 -6
- package/dist/schema-building/utils.js.map +1 -1
- package/dist/subgraph/{subgraph.d.ts → types.d.ts} +5 -8
- package/dist/subgraph/types.js +3 -0
- package/dist/subgraph/types.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/utils/composition-version.js +1 -1
- package/dist/utils/integer-constants.d.ts +0 -1
- package/dist/utils/integer-constants.js +1 -2
- package/dist/utils/integer-constants.js.map +1 -1
- package/dist/utils/string-constants.d.ts +2 -7
- package/dist/utils/string-constants.js +3 -30
- package/dist/utils/string-constants.js.map +1 -1
- package/dist/utils/types.d.ts +1 -0
- package/dist/utils/types.js +3 -0
- package/dist/utils/types.js.map +1 -0
- package/dist/utils/utils.d.ts +10 -74
- package/dist/utils/utils.js +33 -386
- package/dist/utils/utils.js.map +1 -1
- package/dist/{federation → v1/federation}/federation-factory.d.ts +18 -17
- package/dist/{federation → v1/federation}/federation-factory.js +202 -199
- package/dist/v1/federation/federation-factory.js.map +1 -0
- package/dist/{federation → v1/federation}/utils.d.ts +11 -35
- package/dist/{federation → v1/federation}/utils.js +8 -8
- package/dist/v1/federation/utils.js.map +1 -0
- package/dist/{federation → v1/federation}/walkers.d.ts +1 -1
- package/dist/{federation → v1/federation}/walkers.js +10 -10
- package/dist/v1/federation/walkers.js.map +1 -0
- package/dist/{normalization → v1/normalization}/directive-definition-data.d.ts +1 -1
- package/dist/{normalization → v1/normalization}/directive-definition-data.js +2 -2
- package/dist/v1/normalization/directive-definition-data.js.map +1 -0
- package/dist/{normalization → v1/normalization}/normalization-factory.d.ts +29 -54
- package/dist/{normalization → v1/normalization}/normalization-factory.js +200 -201
- package/dist/v1/normalization/normalization-factory.js.map +1 -0
- package/dist/{normalization → v1/normalization}/utils.d.ts +2 -2
- package/dist/{normalization → v1/normalization}/utils.js +33 -34
- package/dist/v1/normalization/utils.js.map +1 -0
- package/dist/{normalization → v1/normalization}/walkers.js +37 -35
- package/dist/v1/normalization/walkers.js.map +1 -0
- package/dist/{schema-building → v1/schema-building}/type-merging.d.ts +1 -1
- package/dist/{schema-building → v1/schema-building}/type-merging.js +4 -4
- package/dist/v1/schema-building/type-merging.js.map +1 -0
- package/dist/v1/subgraph/subgraph.d.ts +1 -0
- package/dist/v1/subgraph/subgraph.js.map +1 -0
- package/dist/{utils → v1/utils}/constants.d.ts +1 -2
- package/dist/{utils → v1/utils}/constants.js +7 -8
- package/dist/v1/utils/constants.js.map +1 -0
- package/dist/v1/utils/integer-constants.d.ts +1 -0
- package/dist/v1/utils/integer-constants.js +5 -0
- package/dist/v1/utils/integer-constants.js.map +1 -0
- package/dist/v1/utils/string-constants.d.ts +5 -0
- package/dist/v1/utils/string-constants.js +32 -0
- package/dist/v1/utils/string-constants.js.map +1 -0
- package/dist/v1/utils/utils.d.ts +35 -0
- package/dist/v1/utils/utils.js +330 -0
- package/dist/v1/utils/utils.js.map +1 -0
- package/dist/v1/warnings/warnings.d.ts +9 -0
- package/dist/v1/warnings/warnings.js +104 -0
- package/dist/v1/warnings/warnings.js.map +1 -0
- package/dist/warnings/warnings.d.ts +0 -8
- package/dist/warnings/warnings.js +0 -100
- package/dist/warnings/warnings.js.map +1 -1
- package/package.json +2 -2
- package/dist/federation/federation-factory.js.map +0 -1
- package/dist/federation/utils.js.map +0 -1
- package/dist/federation/walkers.js.map +0 -1
- package/dist/normalization/directive-definition-data.js.map +0 -1
- package/dist/normalization/normalization-factory.js.map +0 -1
- package/dist/normalization/utils.js.map +0 -1
- package/dist/normalization/walkers.js.map +0 -1
- package/dist/schema-building/type-definition-data.js.map +0 -1
- package/dist/schema-building/type-merging.js.map +0 -1
- package/dist/subgraph/subgraph.js.map +0 -1
- package/dist/utils/constants.js.map +0 -1
- /package/dist/{normalization → v1/normalization}/walkers.d.ts +0 -0
- /package/dist/{subgraph → v1/subgraph}/subgraph.js +0 -0
|
@@ -5,26 +5,29 @@ 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");
|
|
24
27
|
function normalizeSubgraphFromString(subgraphSDL, noLocation = true) {
|
|
25
28
|
const { error, documentNode } = (0, utils_1.safeParse)(subgraphSDL, noLocation);
|
|
26
29
|
if (error || !documentNode) {
|
|
27
|
-
return { errors: [(0, errors_1.subgraphInvalidSyntaxError)(error)], warnings: [] };
|
|
30
|
+
return { errors: [(0, errors_1.subgraphInvalidSyntaxError)(error)], success: false, warnings: [] };
|
|
28
31
|
}
|
|
29
32
|
const normalizationFactory = new NormalizationFactory(new graph_1.Graph());
|
|
30
33
|
return normalizationFactory.normalize(documentNode);
|
|
@@ -84,13 +87,13 @@ class NormalizationFactory {
|
|
|
84
87
|
for (const [baseDirectiveName, baseDirectiveDefinition] of constants_1.BASE_DIRECTIVE_DEFINITION_BY_DIRECTIVE_NAME) {
|
|
85
88
|
this.directiveDefinitionByDirectiveName.set(baseDirectiveName, baseDirectiveDefinition);
|
|
86
89
|
}
|
|
87
|
-
this.subgraphName = subgraphName ||
|
|
90
|
+
this.subgraphName = subgraphName || string_constants_2.NOT_APPLICABLE;
|
|
88
91
|
this.internalGraph = internalGraph;
|
|
89
92
|
this.internalGraph.setSubgraphName(this.subgraphName);
|
|
90
93
|
this.schemaData = {
|
|
91
94
|
directivesByDirectiveName: new Map(),
|
|
92
95
|
kind: graphql_1.Kind.SCHEMA_DEFINITION,
|
|
93
|
-
name:
|
|
96
|
+
name: string_constants_2.SCHEMA,
|
|
94
97
|
operationTypes: new Map(),
|
|
95
98
|
};
|
|
96
99
|
}
|
|
@@ -109,7 +112,7 @@ class NormalizationFactory {
|
|
|
109
112
|
case graphql_1.Kind.SCALAR_TYPE_DEFINITION:
|
|
110
113
|
return { hasUnhandledError: false, typeString: '' };
|
|
111
114
|
default:
|
|
112
|
-
return { hasUnhandledError: true, typeString: (0,
|
|
115
|
+
return { hasUnhandledError: true, typeString: (0, utils_5.kindToTypeString)(parentData.kind) };
|
|
113
116
|
}
|
|
114
117
|
}
|
|
115
118
|
validateArguments(fieldData, fieldPath) {
|
|
@@ -142,7 +145,7 @@ class NormalizationFactory {
|
|
|
142
145
|
const requiresScopes = [];
|
|
143
146
|
for (const directiveNode of node.directives) {
|
|
144
147
|
const directiveName = directiveNode.name.value;
|
|
145
|
-
if (directiveName ===
|
|
148
|
+
if (directiveName === string_constants_2.AUTHENTICATED) {
|
|
146
149
|
// @authenticated is not repeatable
|
|
147
150
|
if (requiresAuthentication) {
|
|
148
151
|
return;
|
|
@@ -150,7 +153,7 @@ class NormalizationFactory {
|
|
|
150
153
|
requiresAuthentication = true;
|
|
151
154
|
continue;
|
|
152
155
|
}
|
|
153
|
-
if (directiveName !==
|
|
156
|
+
if (directiveName !== string_constants_2.REQUIRES_SCOPES) {
|
|
154
157
|
continue;
|
|
155
158
|
}
|
|
156
159
|
// @requiresScopes is not repeatable
|
|
@@ -178,7 +181,7 @@ class NormalizationFactory {
|
|
|
178
181
|
return;
|
|
179
182
|
}
|
|
180
183
|
const scopesArgument = directiveNode.arguments[0];
|
|
181
|
-
if (scopesArgument.name.value !==
|
|
184
|
+
if (scopesArgument.name.value !== string_constants_2.SCOPES || scopesArgument.value.kind !== graphql_1.Kind.LIST) {
|
|
182
185
|
return;
|
|
183
186
|
}
|
|
184
187
|
const orScopes = scopesArgument.value.values;
|
|
@@ -207,7 +210,7 @@ class NormalizationFactory {
|
|
|
207
210
|
return authorizationData;
|
|
208
211
|
}
|
|
209
212
|
isTypeNameRootType(typeName) {
|
|
210
|
-
return
|
|
213
|
+
return string_constants_2.ROOT_TYPE_NAMES.has(typeName) || this.operationTypeNodeByTypeName.has(typeName);
|
|
211
214
|
}
|
|
212
215
|
isArgumentValueValid(typeNode, argumentValue) {
|
|
213
216
|
if (argumentValue.kind === graphql_1.Kind.NULL) {
|
|
@@ -228,37 +231,37 @@ class NormalizationFactory {
|
|
|
228
231
|
}
|
|
229
232
|
case graphql_1.Kind.NAMED_TYPE: {
|
|
230
233
|
switch (typeNode.name.value) {
|
|
231
|
-
case
|
|
234
|
+
case string_constants_2.BOOLEAN_SCALAR: {
|
|
232
235
|
return argumentValue.kind === graphql_1.Kind.BOOLEAN;
|
|
233
236
|
}
|
|
234
|
-
case
|
|
237
|
+
case string_constants_2.FLOAT_SCALAR: {
|
|
235
238
|
return argumentValue.kind === graphql_1.Kind.FLOAT || argumentValue.kind === graphql_1.Kind.INT;
|
|
236
239
|
}
|
|
237
|
-
case
|
|
240
|
+
case string_constants_2.ID_SCALAR: {
|
|
238
241
|
return argumentValue.kind === graphql_1.Kind.STRING || argumentValue.kind === graphql_1.Kind.INT;
|
|
239
242
|
}
|
|
240
|
-
case
|
|
243
|
+
case string_constants_2.INT_SCALAR: {
|
|
241
244
|
return argumentValue.kind === graphql_1.Kind.INT;
|
|
242
245
|
}
|
|
243
|
-
case
|
|
246
|
+
case string_constants_2.FIELD_SET_SCALAR:
|
|
244
247
|
// intentional fallthrough
|
|
245
|
-
case
|
|
248
|
+
case string_constants_2.SCOPE_SCALAR:
|
|
246
249
|
// intentional fallthrough
|
|
247
|
-
case
|
|
250
|
+
case string_constants_2.STRING_SCALAR: {
|
|
248
251
|
return argumentValue.kind === graphql_1.Kind.STRING;
|
|
249
252
|
}
|
|
250
|
-
case
|
|
253
|
+
case string_constants_2.LINK_IMPORT: {
|
|
251
254
|
return true;
|
|
252
255
|
}
|
|
253
|
-
case
|
|
256
|
+
case string_constants_2.LINK_PURPOSE: {
|
|
254
257
|
if (argumentValue.kind !== graphql_1.Kind.ENUM) {
|
|
255
258
|
return false;
|
|
256
259
|
}
|
|
257
|
-
return argumentValue.value ===
|
|
260
|
+
return argumentValue.value === string_constants_2.SECURITY || argumentValue.value === string_constants_2.EXECUTION;
|
|
258
261
|
}
|
|
259
|
-
case
|
|
262
|
+
case string_constants_2.SUBSCRIPTION_FIELD_CONDITION:
|
|
260
263
|
// intentional fallthrough
|
|
261
|
-
case
|
|
264
|
+
case string_constants_2.SUBSCRIPTION_FILTER_CONDITION:
|
|
262
265
|
return argumentValue.kind === graphql_1.Kind.OBJECT;
|
|
263
266
|
default: {
|
|
264
267
|
const parentData = this.parentDefinitionDataByTypeName.get(typeNode.name.value);
|
|
@@ -277,7 +280,7 @@ class NormalizationFactory {
|
|
|
277
280
|
if (!enumValue) {
|
|
278
281
|
return false;
|
|
279
282
|
}
|
|
280
|
-
return !enumValue.directivesByDirectiveName.has(
|
|
283
|
+
return !enumValue.directivesByDirectiveName.has(string_constants_2.INACCESSIBLE);
|
|
281
284
|
}
|
|
282
285
|
if (parentData.kind !== graphql_1.Kind.INPUT_OBJECT_TYPE_DEFINITION) {
|
|
283
286
|
return false;
|
|
@@ -294,10 +297,10 @@ class NormalizationFactory {
|
|
|
294
297
|
}
|
|
295
298
|
addInheritedDirectivesToFieldData(fieldDirectivesByDirectiveName) {
|
|
296
299
|
if (this.isParentObjectShareable) {
|
|
297
|
-
(0,
|
|
300
|
+
(0, utils_5.getValueOrDefault)(fieldDirectivesByDirectiveName, string_constants_2.SHAREABLE, () => [(0, utils_5.generateSimpleDirective)(string_constants_2.SHAREABLE)]);
|
|
298
301
|
}
|
|
299
302
|
if (this.isParentObjectExternal) {
|
|
300
|
-
(0,
|
|
303
|
+
(0, utils_5.getValueOrDefault)(fieldDirectivesByDirectiveName, string_constants_2.EXTERNAL, () => [(0, utils_5.generateSimpleDirective)(string_constants_2.EXTERNAL)]);
|
|
301
304
|
}
|
|
302
305
|
return fieldDirectivesByDirectiveName;
|
|
303
306
|
}
|
|
@@ -308,26 +311,26 @@ class NormalizationFactory {
|
|
|
308
311
|
for (const directiveNode of node.directives) {
|
|
309
312
|
const directiveName = directiveNode.name.value;
|
|
310
313
|
// Don't create pointless repetitions of @shareable
|
|
311
|
-
if (directiveName ===
|
|
312
|
-
(0,
|
|
314
|
+
if (directiveName === string_constants_2.SHAREABLE) {
|
|
315
|
+
(0, utils_5.getValueOrDefault)(directivesByDirectiveName, directiveName, () => [directiveNode]);
|
|
313
316
|
}
|
|
314
317
|
else {
|
|
315
|
-
(0,
|
|
318
|
+
(0, utils_5.getValueOrDefault)(directivesByDirectiveName, directiveName, () => []).push(directiveNode);
|
|
316
319
|
}
|
|
317
320
|
if (!(0, utils_3.isNodeKindObject)(node.kind)) {
|
|
318
321
|
continue;
|
|
319
322
|
}
|
|
320
|
-
this.isParentObjectExternal ||= directiveName ===
|
|
321
|
-
this.isParentObjectShareable ||= directiveName ===
|
|
323
|
+
this.isParentObjectExternal ||= directiveName === string_constants_2.EXTERNAL;
|
|
324
|
+
this.isParentObjectShareable ||= directiveName === string_constants_2.SHAREABLE;
|
|
322
325
|
}
|
|
323
326
|
return directivesByDirectiveName;
|
|
324
327
|
}
|
|
325
328
|
validateDirective({ data, definitionData, directiveCoords, directiveNode, errorMessages, requiredArgumentNames, }) {
|
|
326
329
|
const directiveName = directiveNode.name.value;
|
|
327
330
|
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 ===
|
|
331
|
+
const isAuthenticated = directiveName === string_constants_2.AUTHENTICATED;
|
|
332
|
+
const isOverride = directiveName === string_constants_2.OVERRIDE;
|
|
333
|
+
const isRequiresScopes = directiveName === string_constants_2.REQUIRES_SCOPES;
|
|
331
334
|
if (!directiveNode.arguments || directiveNode.arguments.length < 1) {
|
|
332
335
|
if (definitionData.requiredArgumentNames.size > 0) {
|
|
333
336
|
errorMessages.push((0, errors_1.undefinedRequiredArgumentsErrorMessage)(directiveName, requiredArgumentNames, []));
|
|
@@ -367,7 +370,7 @@ class NormalizationFactory {
|
|
|
367
370
|
});
|
|
368
371
|
continue;
|
|
369
372
|
}
|
|
370
|
-
if (!isRequiresScopes || argumentName !==
|
|
373
|
+
if (!isRequiresScopes || argumentName !== string_constants_2.SCOPES) {
|
|
371
374
|
continue;
|
|
372
375
|
}
|
|
373
376
|
this.handleRequiresScopesDirective({
|
|
@@ -383,7 +386,7 @@ class NormalizationFactory {
|
|
|
383
386
|
if (unexpectedArgumentNames.size > 0) {
|
|
384
387
|
errorMessages.push((0, errors_1.unexpectedDirectiveArgumentErrorMessage)(directiveName, [...unexpectedArgumentNames]));
|
|
385
388
|
}
|
|
386
|
-
const undefinedArgumentNames = (0,
|
|
389
|
+
const undefinedArgumentNames = (0, utils_5.getEntriesNotInHashSet)(requiredArgumentNames, definedArgumentNames);
|
|
387
390
|
if (undefinedArgumentNames.length > 0) {
|
|
388
391
|
errorMessages.push((0, errors_1.undefinedRequiredArgumentsErrorMessage)(directiveName, requiredArgumentNames, undefinedArgumentNames));
|
|
389
392
|
}
|
|
@@ -398,7 +401,7 @@ class NormalizationFactory {
|
|
|
398
401
|
if (data.kind !== graphql_1.Kind.FIELD_DEFINITION) {
|
|
399
402
|
this.leafTypeNamesWithAuthorizationDirectives.add(parentTypeName);
|
|
400
403
|
}
|
|
401
|
-
const parentAuthorizationData = (0,
|
|
404
|
+
const parentAuthorizationData = (0, utils_5.getValueOrDefault)(this.authorizationDataByParentTypeName, parentTypeName, () => (0, utils_3.newAuthorizationData)(parentTypeName));
|
|
402
405
|
const authorizationData = (0, utils_3.getAuthorizationDataToUpdate)(parentAuthorizationData, data.node);
|
|
403
406
|
authorizationData.requiredScopes.push(...requiredScopes);
|
|
404
407
|
return errorMessages;
|
|
@@ -420,7 +423,7 @@ class NormalizationFactory {
|
|
|
420
423
|
definitionErrorMessages.push((0, errors_1.invalidDirectiveLocationErrorMessage)(directiveName, directiveLocation));
|
|
421
424
|
}
|
|
422
425
|
if (directiveNodes.length > 1 && !definitionData.isRepeatable) {
|
|
423
|
-
const handledDirectiveNames = (0,
|
|
426
|
+
const handledDirectiveNames = (0, utils_5.getValueOrDefault)(this.invalidRepeatedDirectiveNameByCoords, directiveCoords, () => new Set());
|
|
424
427
|
if (!handledDirectiveNames.has(directiveName)) {
|
|
425
428
|
handledDirectiveNames.add(directiveName);
|
|
426
429
|
definitionErrorMessages.push((0, errors_1.invalidRepeatedDirectiveErrorMessage)(directiveName));
|
|
@@ -437,7 +440,7 @@ class NormalizationFactory {
|
|
|
437
440
|
requiredArgumentNames,
|
|
438
441
|
});
|
|
439
442
|
if (errorMessages.length > 0) {
|
|
440
|
-
this.errors.push((0, errors_1.invalidDirectiveError)(directiveName, directiveCoords, (0,
|
|
443
|
+
this.errors.push((0, errors_1.invalidDirectiveError)(directiveName, directiveCoords, (0, utils_5.numberToOrdinal)(i + 1), errorMessages));
|
|
441
444
|
}
|
|
442
445
|
}
|
|
443
446
|
}
|
|
@@ -480,7 +483,7 @@ class NormalizationFactory {
|
|
|
480
483
|
getNodeExtensionType(isRealExtension, directivesByDirectiveName, isRootType = false) {
|
|
481
484
|
// If the extend keyword is present, it's simply an extension
|
|
482
485
|
if (isRealExtension) {
|
|
483
|
-
return
|
|
486
|
+
return types_1.ExtensionType.REAL;
|
|
484
487
|
}
|
|
485
488
|
/*
|
|
486
489
|
* @extends is not interpreted as an extension under the following circumstances:
|
|
@@ -488,21 +491,21 @@ class NormalizationFactory {
|
|
|
488
491
|
* 2. It's a V2 subgraph
|
|
489
492
|
* 3. And (of course) if @extends isn't defined at all
|
|
490
493
|
*/
|
|
491
|
-
if (isRootType || this.isSubgraphVersionTwo || !directivesByDirectiveName.has(
|
|
492
|
-
return
|
|
494
|
+
if (isRootType || this.isSubgraphVersionTwo || !directivesByDirectiveName.has(string_constants_2.EXTENDS)) {
|
|
495
|
+
return types_1.ExtensionType.NONE;
|
|
493
496
|
}
|
|
494
497
|
// If it's a V1 subgraph and defines @extends, it is considered an extension across subgraphs
|
|
495
|
-
return
|
|
498
|
+
return types_1.ExtensionType.EXTENDS;
|
|
496
499
|
}
|
|
497
500
|
setParentDataExtensionType(parentData, incomingExtensionType) {
|
|
498
501
|
switch (parentData.extensionType) {
|
|
499
|
-
case
|
|
502
|
+
case types_1.ExtensionType.EXTENDS:
|
|
500
503
|
// intentional fallthrough
|
|
501
|
-
case
|
|
502
|
-
if (incomingExtensionType ===
|
|
504
|
+
case types_1.ExtensionType.NONE: {
|
|
505
|
+
if (incomingExtensionType === types_1.ExtensionType.REAL) {
|
|
503
506
|
return;
|
|
504
507
|
}
|
|
505
|
-
this.errors.push((0, errors_1.duplicateTypeDefinitionError)((0,
|
|
508
|
+
this.errors.push((0, errors_1.duplicateTypeDefinitionError)((0, utils_5.kindToTypeString)(parentData.kind), parentData.name));
|
|
506
509
|
return;
|
|
507
510
|
}
|
|
508
511
|
default: {
|
|
@@ -527,14 +530,14 @@ class NormalizationFactory {
|
|
|
527
530
|
};
|
|
528
531
|
for (const argument of directiveNode.arguments) {
|
|
529
532
|
switch (argument.name.value) {
|
|
530
|
-
case
|
|
533
|
+
case string_constants_2.PROPAGATE: {
|
|
531
534
|
if (argument.value.kind != graphql_1.Kind.BOOLEAN) {
|
|
532
535
|
return;
|
|
533
536
|
}
|
|
534
537
|
configureDescriptionData.propagate = argument.value.value;
|
|
535
538
|
break;
|
|
536
539
|
}
|
|
537
|
-
case
|
|
540
|
+
case string_constants_2.DESCRIPTION_OVERRIDE: {
|
|
538
541
|
if (argument.value.kind != graphql_1.Kind.STRING) {
|
|
539
542
|
return;
|
|
540
543
|
}
|
|
@@ -552,7 +555,7 @@ class NormalizationFactory {
|
|
|
552
555
|
data.configureDescriptionDataBySubgraphName.set(this.subgraphName, configureDescriptionData);
|
|
553
556
|
}
|
|
554
557
|
extractConfigureDescriptionsData(data) {
|
|
555
|
-
const configureDescriptionNodes = data.directivesByDirectiveName.get(
|
|
558
|
+
const configureDescriptionNodes = data.directivesByDirectiveName.get(string_constants_2.CONFIGURE_DESCRIPTION);
|
|
556
559
|
if (configureDescriptionNodes && configureDescriptionNodes.length == 1) {
|
|
557
560
|
this.extractConfigureDescriptionData(data, configureDescriptionNodes[0]);
|
|
558
561
|
}
|
|
@@ -581,13 +584,13 @@ class NormalizationFactory {
|
|
|
581
584
|
this.extractImplementedInterfaceTypeNames(node, data.implementedInterfaceTypeNames);
|
|
582
585
|
data.description ||= (0, utils_1.formatDescription)('description' in node ? node.description : undefined);
|
|
583
586
|
this.extractConfigureDescriptionsData(data);
|
|
584
|
-
data.isEntity ||= data.directivesByDirectiveName.has(
|
|
585
|
-
data.isInaccessible ||= data.directivesByDirectiveName.has(
|
|
587
|
+
data.isEntity ||= data.directivesByDirectiveName.has(string_constants_2.KEY);
|
|
588
|
+
data.isInaccessible ||= data.directivesByDirectiveName.has(string_constants_2.INACCESSIBLE);
|
|
586
589
|
data.subgraphNames.add(this.subgraphName);
|
|
587
590
|
}
|
|
588
591
|
addConcreteTypeNamesForImplementedInterfaces(interfaceTypeNames, concreteTypeName) {
|
|
589
592
|
for (const interfaceName of interfaceTypeNames) {
|
|
590
|
-
(0,
|
|
593
|
+
(0, utils_5.getValueOrDefault)(this.concreteTypeNamesByAbstractTypeName, interfaceName, () => new Set()).add(concreteTypeName);
|
|
591
594
|
this.internalGraph.addEdge(this.internalGraph.addOrUpdateNode(interfaceName, { isAbstract: true }), this.internalGraph.addOrUpdateNode(concreteTypeName), concreteTypeName, true);
|
|
592
595
|
}
|
|
593
596
|
}
|
|
@@ -637,7 +640,7 @@ class NormalizationFactory {
|
|
|
637
640
|
if (handledLocations.has(locationName)) {
|
|
638
641
|
continue;
|
|
639
642
|
}
|
|
640
|
-
if (!
|
|
643
|
+
if (!string_constants_2.EXECUTABLE_DIRECTIVE_LOCATIONS.has(locationName) && !string_constants_1.TYPE_SYSTEM_DIRECTIVE_LOCATIONS.has(locationName)) {
|
|
641
644
|
errorMessages.push((0, errors_1.invalidDirectiveDefinitionLocationErrorMessage)(locationName));
|
|
642
645
|
handledLocations.add(locationName);
|
|
643
646
|
continue;
|
|
@@ -730,7 +733,7 @@ class NormalizationFactory {
|
|
|
730
733
|
isExternalBySubgraphName: new Map([
|
|
731
734
|
[this.subgraphName, isNodeExternalOrShareableResult.isExternal],
|
|
732
735
|
]),
|
|
733
|
-
isInaccessible: directivesByDirectiveName.has(
|
|
736
|
+
isInaccessible: directivesByDirectiveName.has(string_constants_2.INACCESSIBLE),
|
|
734
737
|
isShareableBySubgraphName: new Map([
|
|
735
738
|
[this.subgraphName, isNodeExternalOrShareableResult.isShareable],
|
|
736
739
|
]),
|
|
@@ -755,7 +758,7 @@ class NormalizationFactory {
|
|
|
755
758
|
// Only arguments have renamed paths
|
|
756
759
|
const isArgument = !!renamedPath;
|
|
757
760
|
if (node.defaultValue && !(0, utils_4.areDefaultValuesCompatible)(node.type, node.defaultValue)) {
|
|
758
|
-
this.errors.push((0, errors_1.incompatibleInputValueDefaultValueTypeError)((isArgument ?
|
|
761
|
+
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
762
|
}
|
|
760
763
|
const inputValueData = {
|
|
761
764
|
configureDescriptionDataBySubgraphName: new Map(),
|
|
@@ -790,7 +793,7 @@ class NormalizationFactory {
|
|
|
790
793
|
}
|
|
791
794
|
if (parentData) {
|
|
792
795
|
if (parentData.kind !== graphql_1.Kind.INTERFACE_TYPE_DEFINITION) {
|
|
793
|
-
this.errors.push((0, errors_1.multipleNamedTypeDefinitionError)(typeName, (0,
|
|
796
|
+
this.errors.push((0, errors_1.multipleNamedTypeDefinitionError)(typeName, (0, utils_5.kindToTypeString)(parentData.kind), (0, utils_3.kindToConvertedTypeString)(node.kind)));
|
|
794
797
|
return;
|
|
795
798
|
}
|
|
796
799
|
this.updateCompositeOutputDataByNode(node, parentData, extensionType);
|
|
@@ -802,8 +805,8 @@ class NormalizationFactory {
|
|
|
802
805
|
extensionType,
|
|
803
806
|
fieldDataByFieldName: new Map(),
|
|
804
807
|
implementedInterfaceTypeNames: this.extractImplementedInterfaceTypeNames(node, new Set()),
|
|
805
|
-
isEntity: directivesByDirectiveName.has(
|
|
806
|
-
isInaccessible: directivesByDirectiveName.has(
|
|
808
|
+
isEntity: directivesByDirectiveName.has(string_constants_2.KEY),
|
|
809
|
+
isInaccessible: directivesByDirectiveName.has(string_constants_2.INACCESSIBLE),
|
|
807
810
|
kind: graphql_1.Kind.INTERFACE_TYPE_DEFINITION,
|
|
808
811
|
name: typeName,
|
|
809
812
|
node: (0, ast_1.getMutableInterfaceNode)(node.name),
|
|
@@ -821,11 +824,11 @@ class NormalizationFactory {
|
|
|
821
824
|
}
|
|
822
825
|
switch (operationTypeNode) {
|
|
823
826
|
case graphql_1.OperationTypeNode.MUTATION:
|
|
824
|
-
return
|
|
827
|
+
return string_constants_2.MUTATION;
|
|
825
828
|
case graphql_1.OperationTypeNode.SUBSCRIPTION:
|
|
826
|
-
return
|
|
829
|
+
return string_constants_2.SUBSCRIPTION;
|
|
827
830
|
default:
|
|
828
|
-
return
|
|
831
|
+
return string_constants_2.QUERY;
|
|
829
832
|
}
|
|
830
833
|
}
|
|
831
834
|
addInterfaceObjectFieldsByNode(node) {
|
|
@@ -847,7 +850,7 @@ class NormalizationFactory {
|
|
|
847
850
|
this.addInterfaceObjectFieldsByNode(node);
|
|
848
851
|
if (parentData) {
|
|
849
852
|
if (parentData.kind !== graphql_1.Kind.OBJECT_TYPE_DEFINITION) {
|
|
850
|
-
this.errors.push((0, errors_1.multipleNamedTypeDefinitionError)(typeName, (0,
|
|
853
|
+
this.errors.push((0, errors_1.multipleNamedTypeDefinitionError)(typeName, (0, utils_5.kindToTypeString)(parentData.kind), (0, utils_3.kindToConvertedTypeString)(node.kind)));
|
|
851
854
|
return;
|
|
852
855
|
}
|
|
853
856
|
this.updateCompositeOutputDataByNode(node, parentData, extensionType);
|
|
@@ -862,8 +865,8 @@ class NormalizationFactory {
|
|
|
862
865
|
extensionType,
|
|
863
866
|
fieldDataByFieldName: new Map(),
|
|
864
867
|
implementedInterfaceTypeNames,
|
|
865
|
-
isEntity: directivesByDirectiveName.has(
|
|
866
|
-
isInaccessible: directivesByDirectiveName.has(
|
|
868
|
+
isEntity: directivesByDirectiveName.has(string_constants_2.KEY),
|
|
869
|
+
isInaccessible: directivesByDirectiveName.has(string_constants_2.INACCESSIBLE),
|
|
867
870
|
isRootType,
|
|
868
871
|
kind: graphql_1.Kind.OBJECT_TYPE_DEFINITION,
|
|
869
872
|
name: typeName,
|
|
@@ -884,7 +887,7 @@ class NormalizationFactory {
|
|
|
884
887
|
const extensionType = this.getNodeExtensionType(isRealExtension, directivesByDirectiveName);
|
|
885
888
|
if (parentData) {
|
|
886
889
|
if (parentData.kind !== graphql_1.Kind.ENUM_TYPE_DEFINITION) {
|
|
887
|
-
this.errors.push((0, errors_1.multipleNamedTypeDefinitionError)(typeName, (0,
|
|
890
|
+
this.errors.push((0, errors_1.multipleNamedTypeDefinitionError)(typeName, (0, utils_5.kindToTypeString)(parentData.kind), (0, utils_3.kindToConvertedTypeString)(node.kind)));
|
|
888
891
|
return;
|
|
889
892
|
}
|
|
890
893
|
this.setParentDataExtensionType(parentData, extensionType);
|
|
@@ -916,11 +919,11 @@ class NormalizationFactory {
|
|
|
916
919
|
const extensionType = this.getNodeExtensionType(isRealExtension, directivesByDirectiveName);
|
|
917
920
|
if (parentData) {
|
|
918
921
|
if (parentData.kind !== graphql_1.Kind.INPUT_OBJECT_TYPE_DEFINITION) {
|
|
919
|
-
this.errors.push((0, errors_1.multipleNamedTypeDefinitionError)(typeName, (0,
|
|
922
|
+
this.errors.push((0, errors_1.multipleNamedTypeDefinitionError)(typeName, (0, utils_5.kindToTypeString)(parentData.kind), (0, utils_3.kindToConvertedTypeString)(node.kind)));
|
|
920
923
|
return;
|
|
921
924
|
}
|
|
922
925
|
this.setParentDataExtensionType(parentData, extensionType);
|
|
923
|
-
parentData.isInaccessible ||= directivesByDirectiveName.has(
|
|
926
|
+
parentData.isInaccessible ||= directivesByDirectiveName.has(string_constants_2.INACCESSIBLE);
|
|
924
927
|
parentData.subgraphNames.add(this.subgraphName);
|
|
925
928
|
parentData.description ||= (0, utils_1.formatDescription)('description' in node ? node.description : undefined);
|
|
926
929
|
this.extractConfigureDescriptionsData(parentData);
|
|
@@ -931,7 +934,7 @@ class NormalizationFactory {
|
|
|
931
934
|
directivesByDirectiveName,
|
|
932
935
|
extensionType,
|
|
933
936
|
inputValueDataByValueName: new Map(),
|
|
934
|
-
isInaccessible: directivesByDirectiveName.has(
|
|
937
|
+
isInaccessible: directivesByDirectiveName.has(string_constants_2.INACCESSIBLE),
|
|
935
938
|
kind: graphql_1.Kind.INPUT_OBJECT_TYPE_DEFINITION,
|
|
936
939
|
name: typeName,
|
|
937
940
|
node: (0, ast_1.getMutableInputObjectNode)(node.name),
|
|
@@ -950,7 +953,7 @@ class NormalizationFactory {
|
|
|
950
953
|
const extensionType = this.getNodeExtensionType(isRealExtension, directivesByDirectiveName);
|
|
951
954
|
if (parentData) {
|
|
952
955
|
if (parentData.kind !== graphql_1.Kind.SCALAR_TYPE_DEFINITION) {
|
|
953
|
-
this.errors.push((0, errors_1.multipleNamedTypeDefinitionError)(typeName, (0,
|
|
956
|
+
this.errors.push((0, errors_1.multipleNamedTypeDefinitionError)(typeName, (0, utils_5.kindToTypeString)(parentData.kind), (0, utils_3.kindToConvertedTypeString)(node.kind)));
|
|
954
957
|
return;
|
|
955
958
|
}
|
|
956
959
|
this.setParentDataExtensionType(parentData, extensionType);
|
|
@@ -982,7 +985,7 @@ class NormalizationFactory {
|
|
|
982
985
|
this.errors.push((0, errors_1.duplicateUnionMemberDefinitionError)(unionTypeName, memberTypeName));
|
|
983
986
|
continue;
|
|
984
987
|
}
|
|
985
|
-
(0,
|
|
988
|
+
(0, utils_5.getValueOrDefault)(this.concreteTypeNamesByAbstractTypeName, unionTypeName, () => new Set()).add(memberTypeName);
|
|
986
989
|
/*
|
|
987
990
|
* Scalars are never valid Union member types.
|
|
988
991
|
* However, base scalars are not upserted to the type definition data.
|
|
@@ -1005,7 +1008,7 @@ class NormalizationFactory {
|
|
|
1005
1008
|
this.addConcreteTypeNamesForUnion(node);
|
|
1006
1009
|
if (parentData) {
|
|
1007
1010
|
if (parentData.kind !== graphql_1.Kind.UNION_TYPE_DEFINITION) {
|
|
1008
|
-
this.errors.push((0, errors_1.multipleNamedTypeDefinitionError)(typeName, (0,
|
|
1011
|
+
this.errors.push((0, errors_1.multipleNamedTypeDefinitionError)(typeName, (0, utils_5.kindToTypeString)(parentData.kind), (0, utils_3.kindToConvertedTypeString)(node.kind)));
|
|
1009
1012
|
return;
|
|
1010
1013
|
}
|
|
1011
1014
|
this.setParentDataExtensionType(parentData, extensionType);
|
|
@@ -1038,7 +1041,7 @@ class NormalizationFactory {
|
|
|
1038
1041
|
}
|
|
1039
1042
|
// validation happens elsewhere
|
|
1040
1043
|
for (const directive of node.directives) {
|
|
1041
|
-
if (directive.name.value !==
|
|
1044
|
+
if (directive.name.value !== string_constants_2.KEY) {
|
|
1042
1045
|
continue;
|
|
1043
1046
|
}
|
|
1044
1047
|
if (!directive.arguments || directive.arguments.length < 1) {
|
|
@@ -1047,13 +1050,13 @@ class NormalizationFactory {
|
|
|
1047
1050
|
let keyFieldSet;
|
|
1048
1051
|
let isUnresolvable = false;
|
|
1049
1052
|
for (const arg of directive.arguments) {
|
|
1050
|
-
if (arg.name.value ===
|
|
1053
|
+
if (arg.name.value === string_constants_2.RESOLVABLE) {
|
|
1051
1054
|
if (arg.value.kind === graphql_1.Kind.BOOLEAN && !arg.value.value) {
|
|
1052
1055
|
isUnresolvable = true;
|
|
1053
1056
|
}
|
|
1054
1057
|
continue;
|
|
1055
1058
|
}
|
|
1056
|
-
if (arg.name.value !==
|
|
1059
|
+
if (arg.name.value !== string_constants_2.FIELDS) {
|
|
1057
1060
|
keyFieldSet = undefined;
|
|
1058
1061
|
break;
|
|
1059
1062
|
}
|
|
@@ -1072,7 +1075,7 @@ class NormalizationFactory {
|
|
|
1072
1075
|
if (data.implementedInterfaceTypeNames.size < 1) {
|
|
1073
1076
|
return;
|
|
1074
1077
|
}
|
|
1075
|
-
const isParentInaccessible = data.directivesByDirectiveName.has(
|
|
1078
|
+
const isParentInaccessible = data.directivesByDirectiveName.has(string_constants_2.INACCESSIBLE);
|
|
1076
1079
|
const implementationErrorsMap = new Map();
|
|
1077
1080
|
const invalidImplementationTypeStringByTypeName = new Map();
|
|
1078
1081
|
let doesInterfaceImplementItself = false;
|
|
@@ -1083,7 +1086,7 @@ class NormalizationFactory {
|
|
|
1083
1086
|
continue;
|
|
1084
1087
|
}
|
|
1085
1088
|
if (interfaceData.kind !== graphql_1.Kind.INTERFACE_TYPE_DEFINITION) {
|
|
1086
|
-
invalidImplementationTypeStringByTypeName.set(interfaceData.name, (0,
|
|
1089
|
+
invalidImplementationTypeStringByTypeName.set(interfaceData.name, (0, utils_5.kindToTypeString)(interfaceData.kind));
|
|
1087
1090
|
continue;
|
|
1088
1091
|
}
|
|
1089
1092
|
if (data.name === interfaceData.name) {
|
|
@@ -1169,7 +1172,7 @@ class NormalizationFactory {
|
|
|
1169
1172
|
this.errors.push((0, errors_1.selfImplementationError)(data.name));
|
|
1170
1173
|
}
|
|
1171
1174
|
if (implementationErrorsMap.size > 0) {
|
|
1172
|
-
this.errors.push((0, errors_1.invalidInterfaceImplementationError)(data.name, (0,
|
|
1175
|
+
this.errors.push((0, errors_1.invalidInterfaceImplementationError)(data.name, (0, utils_5.kindToTypeString)(data.kind), implementationErrorsMap));
|
|
1173
1176
|
}
|
|
1174
1177
|
}
|
|
1175
1178
|
handleAuthenticatedDirective(data, parentTypeName) {
|
|
@@ -1181,7 +1184,7 @@ class NormalizationFactory {
|
|
|
1181
1184
|
if (data.kind !== graphql_1.Kind.FIELD_DEFINITION) {
|
|
1182
1185
|
this.leafTypeNamesWithAuthorizationDirectives.add(parentTypeName);
|
|
1183
1186
|
}
|
|
1184
|
-
const parentAuthorizationData = (0,
|
|
1187
|
+
const parentAuthorizationData = (0, utils_5.getValueOrDefault)(this.authorizationDataByParentTypeName, parentTypeName, () => (0, utils_3.newAuthorizationData)(parentTypeName));
|
|
1185
1188
|
(0, utils_3.getAuthorizationDataToUpdate)(parentAuthorizationData, data.node).requiresAuthentication = true;
|
|
1186
1189
|
}
|
|
1187
1190
|
handleOverrideDirective({ data, directiveCoords, errorMessages, targetSubgraphName }) {
|
|
@@ -1189,8 +1192,8 @@ class NormalizationFactory {
|
|
|
1189
1192
|
errorMessages.push((0, errors_1.equivalentSourceAndTargetOverrideErrorMessage)(targetSubgraphName, directiveCoords));
|
|
1190
1193
|
return;
|
|
1191
1194
|
}
|
|
1192
|
-
const overrideDataForSubgraph = (0,
|
|
1193
|
-
(0,
|
|
1195
|
+
const overrideDataForSubgraph = (0, utils_5.getValueOrDefault)(this.overridesByTargetSubgraphName, targetSubgraphName, () => new Map());
|
|
1196
|
+
(0, utils_5.getValueOrDefault)(overrideDataForSubgraph, data.renamedParentTypeName || data.originalParentTypeName, () => new Set()).add(data.name);
|
|
1194
1197
|
}
|
|
1195
1198
|
handleRequiresScopesDirective({ directiveCoords, orScopes, requiredScopes }) {
|
|
1196
1199
|
if (orScopes.length > utils_3.maxOrScopes) {
|
|
@@ -1209,19 +1212,19 @@ class NormalizationFactory {
|
|
|
1209
1212
|
}
|
|
1210
1213
|
getKafkaPublishConfiguration(directive, argumentDataByArgumentName, errorMessages) {
|
|
1211
1214
|
const topics = [];
|
|
1212
|
-
let providerId =
|
|
1215
|
+
let providerId = string_constants_2.DEFAULT_EDFS_PROVIDER_ID;
|
|
1213
1216
|
for (const argumentNode of directive.arguments || []) {
|
|
1214
1217
|
switch (argumentNode.name.value) {
|
|
1215
|
-
case
|
|
1218
|
+
case string_constants_2.TOPIC: {
|
|
1216
1219
|
if (argumentNode.value.kind !== graphql_1.Kind.STRING || argumentNode.value.value.length < 1) {
|
|
1217
|
-
errorMessages.push((0, errors_1.invalidEventSubjectErrorMessage)(
|
|
1220
|
+
errorMessages.push((0, errors_1.invalidEventSubjectErrorMessage)(string_constants_2.TOPIC));
|
|
1218
1221
|
continue;
|
|
1219
1222
|
}
|
|
1220
1223
|
(0, utils_2.validateArgumentTemplateReferences)(argumentNode.value.value, argumentDataByArgumentName, errorMessages);
|
|
1221
1224
|
topics.push(argumentNode.value.value);
|
|
1222
1225
|
break;
|
|
1223
1226
|
}
|
|
1224
|
-
case
|
|
1227
|
+
case string_constants_2.PROVIDER_ID: {
|
|
1225
1228
|
if (argumentNode.value.kind !== graphql_1.Kind.STRING || argumentNode.value.value.length < 1) {
|
|
1226
1229
|
errorMessages.push(errors_1.invalidEventProviderIdErrorMessage);
|
|
1227
1230
|
continue;
|
|
@@ -1234,21 +1237,21 @@ class NormalizationFactory {
|
|
|
1234
1237
|
if (errorMessages.length > 0) {
|
|
1235
1238
|
return;
|
|
1236
1239
|
}
|
|
1237
|
-
return { fieldName: this.childName, providerId, providerType:
|
|
1240
|
+
return { fieldName: this.childName, providerId, providerType: string_constants_2.PROVIDER_TYPE_KAFKA, topics, type: string_constants_2.PUBLISH };
|
|
1238
1241
|
}
|
|
1239
1242
|
getKafkaSubscribeConfiguration(directive, argumentDataByArgumentName, errorMessages) {
|
|
1240
1243
|
const topics = [];
|
|
1241
|
-
let providerId =
|
|
1244
|
+
let providerId = string_constants_2.DEFAULT_EDFS_PROVIDER_ID;
|
|
1242
1245
|
for (const argumentNode of directive.arguments || []) {
|
|
1243
1246
|
switch (argumentNode.name.value) {
|
|
1244
|
-
case
|
|
1247
|
+
case string_constants_2.TOPICS: {
|
|
1245
1248
|
if (argumentNode.value.kind !== graphql_1.Kind.LIST) {
|
|
1246
|
-
errorMessages.push((0, errors_1.invalidEventSubjectsErrorMessage)(
|
|
1249
|
+
errorMessages.push((0, errors_1.invalidEventSubjectsErrorMessage)(string_constants_2.TOPICS));
|
|
1247
1250
|
continue;
|
|
1248
1251
|
}
|
|
1249
1252
|
for (const value of argumentNode.value.values) {
|
|
1250
1253
|
if (value.kind !== graphql_1.Kind.STRING || value.value.length < 1) {
|
|
1251
|
-
errorMessages.push((0, errors_1.invalidEventSubjectsItemErrorMessage)(
|
|
1254
|
+
errorMessages.push((0, errors_1.invalidEventSubjectsItemErrorMessage)(string_constants_2.TOPICS));
|
|
1252
1255
|
break;
|
|
1253
1256
|
}
|
|
1254
1257
|
(0, utils_2.validateArgumentTemplateReferences)(value.value, argumentDataByArgumentName, errorMessages);
|
|
@@ -1256,7 +1259,7 @@ class NormalizationFactory {
|
|
|
1256
1259
|
}
|
|
1257
1260
|
break;
|
|
1258
1261
|
}
|
|
1259
|
-
case
|
|
1262
|
+
case string_constants_2.PROVIDER_ID: {
|
|
1260
1263
|
if (argumentNode.value.kind !== graphql_1.Kind.STRING || argumentNode.value.value.length < 1) {
|
|
1261
1264
|
errorMessages.push(errors_1.invalidEventProviderIdErrorMessage);
|
|
1262
1265
|
continue;
|
|
@@ -1272,26 +1275,26 @@ class NormalizationFactory {
|
|
|
1272
1275
|
return {
|
|
1273
1276
|
fieldName: this.childName,
|
|
1274
1277
|
providerId,
|
|
1275
|
-
providerType:
|
|
1278
|
+
providerType: string_constants_2.PROVIDER_TYPE_KAFKA,
|
|
1276
1279
|
topics: topics,
|
|
1277
|
-
type:
|
|
1280
|
+
type: string_constants_2.SUBSCRIBE,
|
|
1278
1281
|
};
|
|
1279
1282
|
}
|
|
1280
1283
|
getNatsPublishAndRequestConfiguration(eventType, directive, argumentDataByArgumentName, errorMessages) {
|
|
1281
1284
|
const subjects = [];
|
|
1282
|
-
let providerId =
|
|
1285
|
+
let providerId = string_constants_2.DEFAULT_EDFS_PROVIDER_ID;
|
|
1283
1286
|
for (const argumentNode of directive.arguments || []) {
|
|
1284
1287
|
switch (argumentNode.name.value) {
|
|
1285
|
-
case
|
|
1288
|
+
case string_constants_2.SUBJECT: {
|
|
1286
1289
|
if (argumentNode.value.kind !== graphql_1.Kind.STRING || argumentNode.value.value.length < 1) {
|
|
1287
|
-
errorMessages.push((0, errors_1.invalidEventSubjectErrorMessage)(
|
|
1290
|
+
errorMessages.push((0, errors_1.invalidEventSubjectErrorMessage)(string_constants_2.SUBJECT));
|
|
1288
1291
|
continue;
|
|
1289
1292
|
}
|
|
1290
1293
|
(0, utils_2.validateArgumentTemplateReferences)(argumentNode.value.value, argumentDataByArgumentName, errorMessages);
|
|
1291
1294
|
subjects.push(argumentNode.value.value);
|
|
1292
1295
|
break;
|
|
1293
1296
|
}
|
|
1294
|
-
case
|
|
1297
|
+
case string_constants_2.PROVIDER_ID: {
|
|
1295
1298
|
if (argumentNode.value.kind !== graphql_1.Kind.STRING || argumentNode.value.value.length < 1) {
|
|
1296
1299
|
errorMessages.push(errors_1.invalidEventProviderIdErrorMessage);
|
|
1297
1300
|
continue;
|
|
@@ -1304,24 +1307,24 @@ class NormalizationFactory {
|
|
|
1304
1307
|
if (errorMessages.length > 0) {
|
|
1305
1308
|
return;
|
|
1306
1309
|
}
|
|
1307
|
-
return { fieldName: this.childName, providerId, providerType:
|
|
1310
|
+
return { fieldName: this.childName, providerId, providerType: string_constants_2.PROVIDER_TYPE_NATS, subjects, type: eventType };
|
|
1308
1311
|
}
|
|
1309
1312
|
getNatsSubscribeConfiguration(directive, argumentDataByArgumentName, errorMessages) {
|
|
1310
1313
|
const subjects = [];
|
|
1311
|
-
let providerId =
|
|
1314
|
+
let providerId = string_constants_2.DEFAULT_EDFS_PROVIDER_ID;
|
|
1312
1315
|
let consumerInactiveThreshold = integer_constants_1.DEFAULT_CONSUMER_INACTIVE_THRESHOLD;
|
|
1313
1316
|
let consumerName = '';
|
|
1314
1317
|
let streamName = '';
|
|
1315
1318
|
for (const argumentNode of directive.arguments || []) {
|
|
1316
1319
|
switch (argumentNode.name.value) {
|
|
1317
|
-
case
|
|
1320
|
+
case string_constants_2.SUBJECTS: {
|
|
1318
1321
|
if (argumentNode.value.kind !== graphql_1.Kind.LIST) {
|
|
1319
1322
|
// errorMessages.push(invalidEventSubjectsErrorMessage(SUBJECTS));
|
|
1320
1323
|
continue;
|
|
1321
1324
|
}
|
|
1322
1325
|
for (const value of argumentNode.value.values) {
|
|
1323
1326
|
if (value.kind !== graphql_1.Kind.STRING || value.value.length < 1) {
|
|
1324
|
-
errorMessages.push((0, errors_1.invalidEventSubjectsItemErrorMessage)(
|
|
1327
|
+
errorMessages.push((0, errors_1.invalidEventSubjectsItemErrorMessage)(string_constants_2.SUBJECTS));
|
|
1325
1328
|
break;
|
|
1326
1329
|
}
|
|
1327
1330
|
(0, utils_2.validateArgumentTemplateReferences)(value.value, argumentDataByArgumentName, errorMessages);
|
|
@@ -1329,7 +1332,7 @@ class NormalizationFactory {
|
|
|
1329
1332
|
}
|
|
1330
1333
|
break;
|
|
1331
1334
|
}
|
|
1332
|
-
case
|
|
1335
|
+
case string_constants_2.PROVIDER_ID: {
|
|
1333
1336
|
if (argumentNode.value.kind !== graphql_1.Kind.STRING || argumentNode.value.value.length < 1) {
|
|
1334
1337
|
errorMessages.push(errors_1.invalidEventProviderIdErrorMessage);
|
|
1335
1338
|
continue;
|
|
@@ -1337,7 +1340,7 @@ class NormalizationFactory {
|
|
|
1337
1340
|
providerId = argumentNode.value.value;
|
|
1338
1341
|
break;
|
|
1339
1342
|
}
|
|
1340
|
-
case
|
|
1343
|
+
case string_constants_2.STREAM_CONFIGURATION: {
|
|
1341
1344
|
this.usesEdfsNatsStreamConfiguration = true;
|
|
1342
1345
|
if (argumentNode.value.kind !== graphql_1.Kind.OBJECT || argumentNode.value.fields.length < 1) {
|
|
1343
1346
|
errorMessages.push(errors_1.invalidNatsStreamInputErrorMessage);
|
|
@@ -1346,7 +1349,7 @@ class NormalizationFactory {
|
|
|
1346
1349
|
let isValid = true;
|
|
1347
1350
|
const invalidFieldNames = new Set();
|
|
1348
1351
|
const allowedFieldNames = new Set(string_constants_1.STREAM_CONFIGURATION_FIELD_NAMES);
|
|
1349
|
-
const missingRequiredFieldNames = new Set([
|
|
1352
|
+
const missingRequiredFieldNames = new Set([string_constants_2.CONSUMER_NAME, string_constants_2.STREAM_NAME]);
|
|
1350
1353
|
const duplicateFieldNames = new Set();
|
|
1351
1354
|
const invalidRequiredFieldNames = new Set();
|
|
1352
1355
|
for (const field of argumentNode.value.fields) {
|
|
@@ -1368,7 +1371,7 @@ class NormalizationFactory {
|
|
|
1368
1371
|
missingRequiredFieldNames.delete(fieldName);
|
|
1369
1372
|
}
|
|
1370
1373
|
switch (fieldName) {
|
|
1371
|
-
case
|
|
1374
|
+
case string_constants_2.CONSUMER_NAME:
|
|
1372
1375
|
if (field.value.kind != graphql_1.Kind.STRING || field.value.value.length < 1) {
|
|
1373
1376
|
invalidRequiredFieldNames.add(fieldName);
|
|
1374
1377
|
isValid = false;
|
|
@@ -1376,7 +1379,7 @@ class NormalizationFactory {
|
|
|
1376
1379
|
}
|
|
1377
1380
|
consumerName = field.value.value;
|
|
1378
1381
|
break;
|
|
1379
|
-
case
|
|
1382
|
+
case string_constants_2.STREAM_NAME:
|
|
1380
1383
|
if (field.value.kind != graphql_1.Kind.STRING || field.value.value.length < 1) {
|
|
1381
1384
|
invalidRequiredFieldNames.add(fieldName);
|
|
1382
1385
|
isValid = false;
|
|
@@ -1384,9 +1387,9 @@ class NormalizationFactory {
|
|
|
1384
1387
|
}
|
|
1385
1388
|
streamName = field.value.value;
|
|
1386
1389
|
break;
|
|
1387
|
-
case
|
|
1390
|
+
case string_constants_2.CONSUMER_INACTIVE_THRESHOLD:
|
|
1388
1391
|
if (field.value.kind != graphql_1.Kind.INT) {
|
|
1389
|
-
errorMessages.push((0, errors_1.invalidArgumentValueErrorMessage)((0, graphql_1.print)(field.value), 'edfs__NatsStreamConfiguration', `consumerInactiveThreshold`,
|
|
1392
|
+
errorMessages.push((0, errors_1.invalidArgumentValueErrorMessage)((0, graphql_1.print)(field.value), 'edfs__NatsStreamConfiguration', `consumerInactiveThreshold`, string_constants_2.INT_SCALAR));
|
|
1390
1393
|
isValid = false;
|
|
1391
1394
|
continue;
|
|
1392
1395
|
}
|
|
@@ -1395,7 +1398,7 @@ class NormalizationFactory {
|
|
|
1395
1398
|
consumerInactiveThreshold = parseInt(field.value.value, 10);
|
|
1396
1399
|
}
|
|
1397
1400
|
catch (e) {
|
|
1398
|
-
errorMessages.push((0, errors_1.invalidArgumentValueErrorMessage)((0, graphql_1.print)(field.value), 'edfs__NatsStreamConfiguration', `consumerInactiveThreshold`,
|
|
1401
|
+
errorMessages.push((0, errors_1.invalidArgumentValueErrorMessage)((0, graphql_1.print)(field.value), 'edfs__NatsStreamConfiguration', `consumerInactiveThreshold`, string_constants_2.INT_SCALAR));
|
|
1399
1402
|
isValid = false;
|
|
1400
1403
|
}
|
|
1401
1404
|
break;
|
|
@@ -1414,16 +1417,16 @@ class NormalizationFactory {
|
|
|
1414
1417
|
consumerInactiveThreshold = integer_constants_1.DEFAULT_CONSUMER_INACTIVE_THRESHOLD;
|
|
1415
1418
|
this.warnings.push((0, warnings_1.consumerInactiveThresholdInvalidValueWarning)(this.subgraphName, `The value has been set to ${integer_constants_1.DEFAULT_CONSUMER_INACTIVE_THRESHOLD}.`));
|
|
1416
1419
|
}
|
|
1417
|
-
else if (consumerInactiveThreshold >
|
|
1420
|
+
else if (consumerInactiveThreshold > integer_constants_2.MAX_INT32) {
|
|
1418
1421
|
consumerInactiveThreshold = 0;
|
|
1419
1422
|
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
1423
|
}
|
|
1421
1424
|
return {
|
|
1422
1425
|
fieldName: this.childName,
|
|
1423
1426
|
providerId,
|
|
1424
|
-
providerType:
|
|
1427
|
+
providerType: string_constants_2.PROVIDER_TYPE_NATS,
|
|
1425
1428
|
subjects,
|
|
1426
|
-
type:
|
|
1429
|
+
type: string_constants_2.SUBSCRIBE,
|
|
1427
1430
|
...(consumerName && streamName
|
|
1428
1431
|
? {
|
|
1429
1432
|
streamConfiguration: {
|
|
@@ -1443,7 +1446,7 @@ class NormalizationFactory {
|
|
|
1443
1446
|
const fieldPath = `${parentTypeName}.${node.name.value}`;
|
|
1444
1447
|
const isSubscription = this.getOperationTypeNodeForRootTypeName(parentTypeName) === graphql_1.OperationTypeNode.SUBSCRIPTION;
|
|
1445
1448
|
for (const directiveNode of node.directives) {
|
|
1446
|
-
if (directiveNode.name.value !==
|
|
1449
|
+
if (directiveNode.name.value !== string_constants_2.SUBSCRIPTION_FILTER) {
|
|
1447
1450
|
continue;
|
|
1448
1451
|
}
|
|
1449
1452
|
if (!isSubscription) {
|
|
@@ -1462,21 +1465,21 @@ class NormalizationFactory {
|
|
|
1462
1465
|
const errorMessages = [];
|
|
1463
1466
|
let eventConfiguration;
|
|
1464
1467
|
switch (directive.name.value) {
|
|
1465
|
-
case
|
|
1468
|
+
case string_constants_2.EDFS_KAFKA_PUBLISH:
|
|
1466
1469
|
eventConfiguration = this.getKafkaPublishConfiguration(directive, argumentDataByArgumentName, errorMessages);
|
|
1467
1470
|
break;
|
|
1468
|
-
case
|
|
1471
|
+
case string_constants_2.EDFS_KAFKA_SUBSCRIBE:
|
|
1469
1472
|
eventConfiguration = this.getKafkaSubscribeConfiguration(directive, argumentDataByArgumentName, errorMessages);
|
|
1470
1473
|
break;
|
|
1471
|
-
case
|
|
1472
|
-
eventConfiguration = this.getNatsPublishAndRequestConfiguration(
|
|
1474
|
+
case string_constants_2.EDFS_NATS_PUBLISH: {
|
|
1475
|
+
eventConfiguration = this.getNatsPublishAndRequestConfiguration(string_constants_2.PUBLISH, directive, argumentDataByArgumentName, errorMessages);
|
|
1473
1476
|
break;
|
|
1474
1477
|
}
|
|
1475
|
-
case
|
|
1476
|
-
eventConfiguration = this.getNatsPublishAndRequestConfiguration(
|
|
1478
|
+
case string_constants_2.EDFS_NATS_REQUEST: {
|
|
1479
|
+
eventConfiguration = this.getNatsPublishAndRequestConfiguration(string_constants_2.REQUEST, directive, argumentDataByArgumentName, errorMessages);
|
|
1477
1480
|
break;
|
|
1478
1481
|
}
|
|
1479
|
-
case
|
|
1482
|
+
case string_constants_2.EDFS_NATS_SUBSCRIBE: {
|
|
1480
1483
|
eventConfiguration = this.getNatsSubscribeConfiguration(directive, argumentDataByArgumentName, errorMessages);
|
|
1481
1484
|
break;
|
|
1482
1485
|
}
|
|
@@ -1491,17 +1494,17 @@ class NormalizationFactory {
|
|
|
1491
1494
|
if (!eventConfiguration) {
|
|
1492
1495
|
continue;
|
|
1493
1496
|
}
|
|
1494
|
-
(0,
|
|
1497
|
+
(0, utils_5.getValueOrDefault)(this.eventsConfigurations, this.renamedParentTypeName || this.originalParentTypeName, () => []).push(eventConfiguration);
|
|
1495
1498
|
}
|
|
1496
1499
|
}
|
|
1497
1500
|
getValidEventsDirectiveNamesForOperationTypeNode(operationTypeNode) {
|
|
1498
1501
|
switch (operationTypeNode) {
|
|
1499
1502
|
case graphql_1.OperationTypeNode.MUTATION:
|
|
1500
|
-
return new Set([
|
|
1503
|
+
return new Set([string_constants_2.EDFS_KAFKA_PUBLISH, string_constants_2.EDFS_NATS_PUBLISH, string_constants_2.EDFS_NATS_REQUEST]);
|
|
1501
1504
|
case graphql_1.OperationTypeNode.QUERY:
|
|
1502
|
-
return new Set([
|
|
1505
|
+
return new Set([string_constants_2.EDFS_NATS_REQUEST]);
|
|
1503
1506
|
case graphql_1.OperationTypeNode.SUBSCRIPTION:
|
|
1504
|
-
return new Set([
|
|
1507
|
+
return new Set([string_constants_2.EDFS_KAFKA_SUBSCRIBE, string_constants_2.EDFS_NATS_SUBSCRIBE]);
|
|
1505
1508
|
}
|
|
1506
1509
|
}
|
|
1507
1510
|
getOperationTypeNodeForRootTypeName(parentTypeName) {
|
|
@@ -1510,11 +1513,11 @@ class NormalizationFactory {
|
|
|
1510
1513
|
return operationTypeNode;
|
|
1511
1514
|
}
|
|
1512
1515
|
switch (parentTypeName) {
|
|
1513
|
-
case
|
|
1516
|
+
case string_constants_2.MUTATION:
|
|
1514
1517
|
return graphql_1.OperationTypeNode.MUTATION;
|
|
1515
|
-
case
|
|
1518
|
+
case string_constants_2.QUERY:
|
|
1516
1519
|
return graphql_1.OperationTypeNode.QUERY;
|
|
1517
|
-
case
|
|
1520
|
+
case string_constants_2.SUBSCRIPTION:
|
|
1518
1521
|
return graphql_1.OperationTypeNode.SUBSCRIPTION;
|
|
1519
1522
|
default:
|
|
1520
1523
|
return;
|
|
@@ -1550,7 +1553,7 @@ class NormalizationFactory {
|
|
|
1550
1553
|
}
|
|
1551
1554
|
if (operationTypeNode === graphql_1.OperationTypeNode.MUTATION) {
|
|
1552
1555
|
const typeString = (0, merge_1.printTypeNode)(fieldData.type);
|
|
1553
|
-
if (typeString !==
|
|
1556
|
+
if (typeString !== string_constants_2.NON_NULLABLE_EDFS_PUBLISH_EVENT_RESULT) {
|
|
1554
1557
|
invalidResponseTypeNameByMutationPath.set(fieldPath, typeString);
|
|
1555
1558
|
}
|
|
1556
1559
|
continue;
|
|
@@ -1580,7 +1583,7 @@ class NormalizationFactory {
|
|
|
1580
1583
|
if (isUnresolvable) {
|
|
1581
1584
|
continue;
|
|
1582
1585
|
}
|
|
1583
|
-
(0,
|
|
1586
|
+
(0, utils_5.getValueOrDefault)(invalidKeyFieldSetsByEntityTypeName, typeName, () => []).push(keyFieldSet);
|
|
1584
1587
|
}
|
|
1585
1588
|
}
|
|
1586
1589
|
validateEventDrivenObjectFields(fieldDataByFieldName, keyFieldNames, nonExternalKeyFieldNameByFieldPath, nonKeyFieldNameByFieldPath) {
|
|
@@ -1596,7 +1599,7 @@ class NormalizationFactory {
|
|
|
1596
1599
|
}
|
|
1597
1600
|
}
|
|
1598
1601
|
isEdfsPublishResultValid() {
|
|
1599
|
-
const data = this.parentDefinitionDataByTypeName.get(
|
|
1602
|
+
const data = this.parentDefinitionDataByTypeName.get(string_constants_2.EDFS_PUBLISH_RESULT);
|
|
1600
1603
|
if (!data) {
|
|
1601
1604
|
return true;
|
|
1602
1605
|
}
|
|
@@ -1610,10 +1613,10 @@ class NormalizationFactory {
|
|
|
1610
1613
|
if (fieldData.argumentDataByArgumentName.size > 0) {
|
|
1611
1614
|
return false;
|
|
1612
1615
|
}
|
|
1613
|
-
if (fieldName !==
|
|
1616
|
+
if (fieldName !== string_constants_2.SUCCESS) {
|
|
1614
1617
|
return false;
|
|
1615
1618
|
}
|
|
1616
|
-
if ((0, merge_1.printTypeNode)(fieldData.type) !==
|
|
1619
|
+
if ((0, merge_1.printTypeNode)(fieldData.type) !== string_constants_2.NON_NULLABLE_BOOLEAN) {
|
|
1617
1620
|
return false;
|
|
1618
1621
|
}
|
|
1619
1622
|
}
|
|
@@ -1628,8 +1631,8 @@ class NormalizationFactory {
|
|
|
1628
1631
|
}
|
|
1629
1632
|
for (const [inputValueName, inputValueData] of streamConfigurationInputData.inputValueDataByValueName) {
|
|
1630
1633
|
switch (inputValueName) {
|
|
1631
|
-
case
|
|
1632
|
-
if ((0, merge_1.printTypeNode)(inputValueData.type) !==
|
|
1634
|
+
case string_constants_2.CONSUMER_INACTIVE_THRESHOLD: {
|
|
1635
|
+
if ((0, merge_1.printTypeNode)(inputValueData.type) !== string_constants_2.NON_NULLABLE_INT) {
|
|
1633
1636
|
return false;
|
|
1634
1637
|
}
|
|
1635
1638
|
if (!inputValueData.defaultValue ||
|
|
@@ -1639,10 +1642,10 @@ class NormalizationFactory {
|
|
|
1639
1642
|
}
|
|
1640
1643
|
break;
|
|
1641
1644
|
}
|
|
1642
|
-
case
|
|
1645
|
+
case string_constants_2.CONSUMER_NAME:
|
|
1643
1646
|
// intentional fallthrough
|
|
1644
|
-
case
|
|
1645
|
-
if ((0, merge_1.printTypeNode)(inputValueData.type) !==
|
|
1647
|
+
case string_constants_2.STREAM_NAME: {
|
|
1648
|
+
if ((0, merge_1.printTypeNode)(inputValueData.type) !== string_constants_2.NON_NULLABLE_STRING) {
|
|
1646
1649
|
return false;
|
|
1647
1650
|
}
|
|
1648
1651
|
break;
|
|
@@ -1666,7 +1669,7 @@ class NormalizationFactory {
|
|
|
1666
1669
|
const invalidObjectTypeNames = new Set();
|
|
1667
1670
|
for (const [typeName, data] of this.parentDefinitionDataByTypeName) {
|
|
1668
1671
|
// validate edfs__PublishResult and edfs__NatsStreamConfiguration separately
|
|
1669
|
-
if (typeName ===
|
|
1672
|
+
if (typeName === string_constants_2.EDFS_PUBLISH_RESULT || typeName === string_constants_2.EDFS_NATS_STREAM_CONFIGURATION) {
|
|
1670
1673
|
continue;
|
|
1671
1674
|
}
|
|
1672
1675
|
if (data.kind !== graphql_1.Kind.OBJECT_TYPE_DEFINITION) {
|
|
@@ -1687,18 +1690,18 @@ class NormalizationFactory {
|
|
|
1687
1690
|
if (!this.isEdfsPublishResultValid()) {
|
|
1688
1691
|
errorMessages.push(errors_1.invalidEdfsPublishResultObjectErrorMessage);
|
|
1689
1692
|
}
|
|
1690
|
-
if (this.edfsDirectiveReferences.has(
|
|
1691
|
-
const streamConfigurationInputData = this.parentDefinitionDataByTypeName.get(
|
|
1693
|
+
if (this.edfsDirectiveReferences.has(string_constants_2.EDFS_NATS_SUBSCRIBE)) {
|
|
1694
|
+
const streamConfigurationInputData = this.parentDefinitionDataByTypeName.get(string_constants_2.EDFS_NATS_STREAM_CONFIGURATION);
|
|
1692
1695
|
if (streamConfigurationInputData &&
|
|
1693
1696
|
this.usesEdfsNatsStreamConfiguration &&
|
|
1694
1697
|
!this.isNatsStreamConfigurationInputObjectValid(streamConfigurationInputData)) {
|
|
1695
1698
|
errorMessages.push(errors_1.invalidNatsStreamConfigurationDefinitionErrorMessage);
|
|
1696
1699
|
}
|
|
1697
1700
|
// always add the correct definition to the schema regardless
|
|
1698
|
-
this.parentDefinitionDataByTypeName.delete(
|
|
1701
|
+
this.parentDefinitionDataByTypeName.delete(string_constants_2.EDFS_NATS_STREAM_CONFIGURATION);
|
|
1699
1702
|
definitions.push(constants_1.EDFS_NATS_STREAM_CONFIGURATION_DEFINITION);
|
|
1700
1703
|
}
|
|
1701
|
-
if (this.referencedDirectiveNames.has(
|
|
1704
|
+
if (this.referencedDirectiveNames.has(string_constants_2.LINK)) {
|
|
1702
1705
|
definitions.push(constants_1.LINK_DEFINITION);
|
|
1703
1706
|
definitions.push(constants_1.LINK_IMPORT_DEFINITION);
|
|
1704
1707
|
definitions.push(constants_1.LINK_PURPOSE_DEFINITION);
|
|
@@ -1744,7 +1747,7 @@ class NormalizationFactory {
|
|
|
1744
1747
|
continue;
|
|
1745
1748
|
}
|
|
1746
1749
|
if (memberData.kind !== graphql_1.Kind.OBJECT_TYPE_DEFINITION) {
|
|
1747
|
-
invalidMembers.push(`"${memberName}", which is type "${(0,
|
|
1750
|
+
invalidMembers.push(`"${memberName}", which is type "${(0, utils_5.kindToTypeString)(memberData.kind)}"`);
|
|
1748
1751
|
}
|
|
1749
1752
|
}
|
|
1750
1753
|
if (invalidMembers.length > 0) {
|
|
@@ -1758,12 +1761,12 @@ class NormalizationFactory {
|
|
|
1758
1761
|
const unionTypeName = node.name.value;
|
|
1759
1762
|
for (const member of node.types) {
|
|
1760
1763
|
const memberTypeName = member.name.value;
|
|
1761
|
-
(0,
|
|
1764
|
+
(0, utils_5.getValueOrDefault)(this.concreteTypeNamesByAbstractTypeName, unionTypeName, () => new Set()).add(memberTypeName);
|
|
1762
1765
|
this.internalGraph.addEdge(this.internalGraph.addOrUpdateNode(unionTypeName, { isAbstract: true }), this.internalGraph.addOrUpdateNode(memberTypeName), memberTypeName, true);
|
|
1763
1766
|
}
|
|
1764
1767
|
}
|
|
1765
1768
|
validateAndAddKeyToConfiguration(parentData, keyFieldSetData) {
|
|
1766
|
-
const configurationData = (0,
|
|
1769
|
+
const configurationData = (0, utils_5.getOrThrowError)(this.configurationDataByParentTypeName, (0, utils_4.getParentTypeName)(parentData), 'configurationDataByParentTypeName');
|
|
1767
1770
|
const keys = (0, utils_2.validateKeyFieldSets)(this, parentData, keyFieldSetData.isUnresolvableByKeyFieldSet, configurationData.fieldNames);
|
|
1768
1771
|
if (keys) {
|
|
1769
1772
|
configurationData.keys = keys;
|
|
@@ -1788,7 +1791,7 @@ class NormalizationFactory {
|
|
|
1788
1791
|
continue;
|
|
1789
1792
|
}
|
|
1790
1793
|
if (!directiveDefinition.isRepeatable && directiveNodes.length > 1) {
|
|
1791
|
-
const handledDirectiveNames = (0,
|
|
1794
|
+
const handledDirectiveNames = (0, utils_5.getValueOrDefault)(this.invalidRepeatedDirectiveNameByCoords, directiveCoords, () => new Set());
|
|
1792
1795
|
if (!handledDirectiveNames.has(directiveName)) {
|
|
1793
1796
|
handledDirectiveNames.add(directiveName);
|
|
1794
1797
|
this.errors.push((0, errors_1.invalidDirectiveError)(directiveName, directiveCoords, '1st', [
|
|
@@ -1797,7 +1800,7 @@ class NormalizationFactory {
|
|
|
1797
1800
|
}
|
|
1798
1801
|
continue;
|
|
1799
1802
|
}
|
|
1800
|
-
if (directiveName !==
|
|
1803
|
+
if (directiveName !== string_constants_2.KEY) {
|
|
1801
1804
|
flattenedArray.push(...directiveNodes);
|
|
1802
1805
|
continue;
|
|
1803
1806
|
}
|
|
@@ -1866,7 +1869,7 @@ class NormalizationFactory {
|
|
|
1866
1869
|
// Collect any renamed root types
|
|
1867
1870
|
(0, walkers_1.upsertDirectiveSchemaAndEntityDefinitions)(this, document);
|
|
1868
1871
|
(0, walkers_1.upsertParentsAndChildren)(this, document);
|
|
1869
|
-
this.validateDirectives(this.schemaData,
|
|
1872
|
+
this.validateDirectives(this.schemaData, string_constants_2.SCHEMA);
|
|
1870
1873
|
for (const [parentTypeName, parentData] of this.parentDefinitionDataByTypeName) {
|
|
1871
1874
|
this.validateDirectives(parentData, parentTypeName);
|
|
1872
1875
|
}
|
|
@@ -1878,7 +1881,7 @@ class NormalizationFactory {
|
|
|
1878
1881
|
}
|
|
1879
1882
|
const concreteTypeNames = this.concreteTypeNamesByAbstractTypeName.get(interfaceTypeName);
|
|
1880
1883
|
for (const concreteTypeName of concreteTypeNames || []) {
|
|
1881
|
-
const concreteAuthorizationData = (0,
|
|
1884
|
+
const concreteAuthorizationData = (0, utils_5.getValueOrDefault)(this.authorizationDataByParentTypeName, concreteTypeName, () => (0, utils_3.newAuthorizationData)(concreteTypeName));
|
|
1882
1885
|
for (const [fieldName, interfaceFieldAuthorizationData,] of interfaceAuthorizationData.fieldAuthorizationDataByFieldName) {
|
|
1883
1886
|
if (!(0, utils_3.upsertFieldAuthorizationData)(concreteAuthorizationData.fieldAuthorizationDataByFieldName, interfaceFieldAuthorizationData)) {
|
|
1884
1887
|
this.invalidOrScopesHostPaths.add(`${concreteTypeName}.${fieldName}`);
|
|
@@ -1923,16 +1926,16 @@ class NormalizationFactory {
|
|
|
1923
1926
|
definitions.push(directiveDefinition);
|
|
1924
1927
|
}
|
|
1925
1928
|
// subscriptionFilter is temporarily valid only in an EDG
|
|
1926
|
-
if (this.edfsDirectiveReferences.size > 0 && this.referencedDirectiveNames.has(
|
|
1929
|
+
if (this.edfsDirectiveReferences.size > 0 && this.referencedDirectiveNames.has(string_constants_2.SUBSCRIPTION_FILTER)) {
|
|
1927
1930
|
definitions.push(constants_1.SUBSCRIPTION_FILTER_DEFINITION);
|
|
1928
1931
|
definitions.push(constants_1.SUBSCRIPTION_FILTER_CONDITION_DEFINITION);
|
|
1929
1932
|
definitions.push(constants_1.SUBSCRIPTION_FIELD_CONDITION_DEFINITION);
|
|
1930
1933
|
definitions.push(constants_1.SUBSCRIPTION_FILTER_VALUE_DEFINITION);
|
|
1931
1934
|
}
|
|
1932
|
-
if (this.referencedDirectiveNames.has(
|
|
1935
|
+
if (this.referencedDirectiveNames.has(string_constants_2.CONFIGURE_DESCRIPTION)) {
|
|
1933
1936
|
definitions.push(constants_1.CONFIGURE_DESCRIPTION_DEFINITION);
|
|
1934
1937
|
}
|
|
1935
|
-
if (this.referencedDirectiveNames.has(
|
|
1938
|
+
if (this.referencedDirectiveNames.has(string_constants_2.CONFIGURE_CHILD_DESCRIPTIONS)) {
|
|
1936
1939
|
definitions.push(constants_1.CONFIGURE_CHILD_DESCRIPTIONS_DEFINITION);
|
|
1937
1940
|
}
|
|
1938
1941
|
for (const directiveDefinition of this.customDirectiveDefinitions.values()) {
|
|
@@ -1947,7 +1950,7 @@ class NormalizationFactory {
|
|
|
1947
1950
|
* */
|
|
1948
1951
|
for (const data of this.invalidConfigureDescriptionNodeDatas) {
|
|
1949
1952
|
if (!data.description) {
|
|
1950
|
-
this.errors.push((0, errors_1.configureDescriptionNoDescriptionError)((0,
|
|
1953
|
+
this.errors.push((0, errors_1.configureDescriptionNoDescriptionError)((0, utils_5.kindToTypeString)(data.kind), data.name));
|
|
1951
1954
|
}
|
|
1952
1955
|
}
|
|
1953
1956
|
for (const [parentTypeName, parentDefinitionData] of this.parentDefinitionDataByTypeName) {
|
|
@@ -1974,8 +1977,8 @@ class NormalizationFactory {
|
|
|
1974
1977
|
const operationTypeNode = this.operationTypeNodeByTypeName.get(parentTypeName);
|
|
1975
1978
|
const isObject = parentDefinitionData.kind === graphql_1.Kind.OBJECT_TYPE_DEFINITION;
|
|
1976
1979
|
if (operationTypeNode) {
|
|
1977
|
-
parentDefinitionData.fieldDataByFieldName.delete(
|
|
1978
|
-
parentDefinitionData.fieldDataByFieldName.delete(
|
|
1980
|
+
parentDefinitionData.fieldDataByFieldName.delete(string_constants_2.SERVICE_FIELD);
|
|
1981
|
+
parentDefinitionData.fieldDataByFieldName.delete(string_constants_2.ENTITIES_FIELD);
|
|
1979
1982
|
}
|
|
1980
1983
|
(0, utils_4.removeIgnoredDirectives)(parentDefinitionData);
|
|
1981
1984
|
(0, utils_4.removeInheritableDirectivesFromObjectParent)(parentDefinitionData);
|
|
@@ -2006,7 +2009,7 @@ class NormalizationFactory {
|
|
|
2006
2009
|
const entityInterfaceData = this.entityInterfaceDataByTypeName.get(parentTypeName);
|
|
2007
2010
|
if (entityInterfaceData) {
|
|
2008
2011
|
entityInterfaceData.fieldDatas = (0, utils_3.fieldDatasToSimpleFieldDatas)(parentDefinitionData.fieldDataByFieldName.values());
|
|
2009
|
-
entityInterfaceData.concreteTypeNames = (0,
|
|
2012
|
+
entityInterfaceData.concreteTypeNames = (0, utils_5.getValueOrDefault)(this.concreteTypeNamesByAbstractTypeName, parentTypeName, () => new Set());
|
|
2010
2013
|
configurationData.isInterfaceObject = entityInterfaceData.isInterfaceObject;
|
|
2011
2014
|
configurationData.entityInterfaceConcreteTypeNames = entityInterfaceData.concreteTypeNames;
|
|
2012
2015
|
}
|
|
@@ -2020,11 +2023,11 @@ class NormalizationFactory {
|
|
|
2020
2023
|
definitions.push(this.getCompositeOutputNodeByData(parentDefinitionData));
|
|
2021
2024
|
// interfaces and objects must define at least one field
|
|
2022
2025
|
if (parentDefinitionData.fieldDataByFieldName.size < 1 && !(0, utils_2.isNodeQuery)(parentTypeName, operationTypeNode)) {
|
|
2023
|
-
this.errors.push((0, errors_1.noFieldDefinitionsError)((0,
|
|
2026
|
+
this.errors.push((0, errors_1.noFieldDefinitionsError)((0, utils_5.kindToTypeString)(parentDefinitionData.kind), parentTypeName));
|
|
2024
2027
|
}
|
|
2025
2028
|
break;
|
|
2026
2029
|
case graphql_1.Kind.SCALAR_TYPE_DEFINITION:
|
|
2027
|
-
if (parentDefinitionData.extensionType ===
|
|
2030
|
+
if (parentDefinitionData.extensionType === types_1.ExtensionType.REAL) {
|
|
2028
2031
|
this.errors.push((0, errors_1.noBaseScalarDefinitionError)(parentTypeName));
|
|
2029
2032
|
break;
|
|
2030
2033
|
}
|
|
@@ -2042,7 +2045,7 @@ class NormalizationFactory {
|
|
|
2042
2045
|
// Check that explicitly defined operations types are valid objects and that their fields are also valid
|
|
2043
2046
|
for (const operationType of Object.values(graphql_1.OperationTypeNode)) {
|
|
2044
2047
|
const operationTypeNode = this.schemaData.operationTypes.get(operationType);
|
|
2045
|
-
const defaultTypeName = (0,
|
|
2048
|
+
const defaultTypeName = (0, utils_5.getOrThrowError)(utils_1.operationTypeNodeToDefaultType, operationType, string_constants_2.OPERATION_TO_DEFAULT);
|
|
2046
2049
|
// If an operation type name was not declared, use the default
|
|
2047
2050
|
const operationTypeName = operationTypeNode ? (0, ast_1.getTypeNodeNamedTypeName)(operationTypeNode.type) : defaultTypeName;
|
|
2048
2051
|
// If a custom type is used, the default type should not be defined
|
|
@@ -2131,34 +2134,33 @@ class NormalizationFactory {
|
|
|
2131
2134
|
}
|
|
2132
2135
|
}
|
|
2133
2136
|
if (this.errors.length > 0) {
|
|
2134
|
-
return { errors: this.errors, warnings: this.warnings };
|
|
2137
|
+
return { success: false, errors: this.errors, warnings: this.warnings };
|
|
2135
2138
|
}
|
|
2136
2139
|
const newAST = {
|
|
2137
2140
|
kind: graphql_1.Kind.DOCUMENT,
|
|
2138
2141
|
definitions,
|
|
2139
2142
|
};
|
|
2140
2143
|
return {
|
|
2141
|
-
|
|
2142
|
-
|
|
2143
|
-
|
|
2144
|
-
|
|
2145
|
-
|
|
2146
|
-
|
|
2147
|
-
|
|
2148
|
-
|
|
2149
|
-
|
|
2150
|
-
|
|
2151
|
-
|
|
2152
|
-
|
|
2153
|
-
|
|
2154
|
-
|
|
2155
|
-
|
|
2156
|
-
|
|
2157
|
-
|
|
2158
|
-
|
|
2159
|
-
|
|
2160
|
-
|
|
2161
|
-
},
|
|
2144
|
+
authorizationDataByParentTypeName: this.authorizationDataByParentTypeName,
|
|
2145
|
+
// configurationDataMap is map of ConfigurationData per type name.
|
|
2146
|
+
// It is an Intermediate configuration object that will be converted to an engine configuration in the router
|
|
2147
|
+
concreteTypeNamesByAbstractTypeName: this.concreteTypeNamesByAbstractTypeName,
|
|
2148
|
+
conditionalFieldDataByCoordinates: this.conditionalFieldDataByCoordinates,
|
|
2149
|
+
configurationDataByTypeName: this.configurationDataByParentTypeName,
|
|
2150
|
+
entityDataByTypeName: this.entityDataByTypeName,
|
|
2151
|
+
entityInterfaces: this.entityInterfaceDataByTypeName,
|
|
2152
|
+
isEventDrivenGraph: this.isSubgraphEventDrivenGraph,
|
|
2153
|
+
isVersionTwo: this.isSubgraphVersionTwo,
|
|
2154
|
+
keyFieldNamesByParentTypeName: this.keyFieldNamesByParentTypeName,
|
|
2155
|
+
operationTypes: this.operationTypeNodeByTypeName,
|
|
2156
|
+
originalTypeNameByRenamedTypeName: this.originalTypeNameByRenamedTypeName,
|
|
2157
|
+
overridesByTargetSubgraphName: this.overridesByTargetSubgraphName,
|
|
2158
|
+
parentDefinitionDataByTypeName: this.parentDefinitionDataByTypeName,
|
|
2159
|
+
persistedDirectiveDefinitionDataByDirectiveName,
|
|
2160
|
+
subgraphAST: newAST,
|
|
2161
|
+
subgraphString: (0, graphql_1.print)(newAST),
|
|
2162
|
+
schema: (0, buildASTSchema_1.buildASTSchema)(newAST, { assumeValid: true, assumeValidSDL: true }),
|
|
2163
|
+
success: true,
|
|
2162
2164
|
warnings: this.warnings,
|
|
2163
2165
|
};
|
|
2164
2166
|
}
|
|
@@ -2192,12 +2194,12 @@ function batchNormalize(subgraphs) {
|
|
|
2192
2194
|
if (!subgraph.name) {
|
|
2193
2195
|
invalidNameErrorMessages.push((0, errors_1.invalidSubgraphNameErrorMessage)(i, subgraphName));
|
|
2194
2196
|
}
|
|
2195
|
-
const
|
|
2196
|
-
if (
|
|
2197
|
-
warnings.push(...
|
|
2197
|
+
const normalizationResult = normalizeSubgraph(subgraph.definitions, subgraph.name, internalGraph);
|
|
2198
|
+
if (normalizationResult.warnings.length > 0) {
|
|
2199
|
+
warnings.push(...normalizationResult.warnings);
|
|
2198
2200
|
}
|
|
2199
|
-
if (
|
|
2200
|
-
validationErrors.push((0, errors_1.subgraphValidationError)(subgraphName, errors));
|
|
2201
|
+
if (!normalizationResult.success) {
|
|
2202
|
+
validationErrors.push((0, errors_1.subgraphValidationError)(subgraphName, normalizationResult.errors));
|
|
2201
2203
|
continue;
|
|
2202
2204
|
}
|
|
2203
2205
|
if (!normalizationResult) {
|
|
@@ -2214,7 +2216,7 @@ function batchNormalize(subgraphs) {
|
|
|
2214
2216
|
concreteTypeNamesByAbstractTypeName.set(abstractTypeName, new Set(incomingConcreteTypeNames));
|
|
2215
2217
|
continue;
|
|
2216
2218
|
}
|
|
2217
|
-
(0,
|
|
2219
|
+
(0, utils_5.addIterableValuesToSet)(incomingConcreteTypeNames, existingConcreteTypeNames);
|
|
2218
2220
|
}
|
|
2219
2221
|
for (const entityData of normalizationResult.entityDataByTypeName.values()) {
|
|
2220
2222
|
(0, utils_3.upsertEntityData)(entityDataByTypeName, entityData);
|
|
@@ -2249,9 +2251,9 @@ function batchNormalize(subgraphs) {
|
|
|
2249
2251
|
warnings.push((0, warnings_1.invalidOverrideTargetSubgraphNameWarning)(targetSubgraphName, originalParentTypeName, [...fieldNames], subgraph.name));
|
|
2250
2252
|
}
|
|
2251
2253
|
else {
|
|
2252
|
-
const overridesData = (0,
|
|
2253
|
-
const existingFieldNames = (0,
|
|
2254
|
-
(0,
|
|
2254
|
+
const overridesData = (0, utils_5.getValueOrDefault)(allOverridesByTargetSubgraphName, targetSubgraphName, () => new Map());
|
|
2255
|
+
const existingFieldNames = (0, utils_5.getValueOrDefault)(overridesData, parentTypeName, () => new Set(fieldNames));
|
|
2256
|
+
(0, utils_5.addIterableValuesToSet)(fieldNames, existingFieldNames);
|
|
2255
2257
|
}
|
|
2256
2258
|
for (const fieldName of fieldNames) {
|
|
2257
2259
|
const fieldPath = `${originalParentTypeName}.${fieldName}`;
|
|
@@ -2276,7 +2278,7 @@ function batchNormalize(subgraphs) {
|
|
|
2276
2278
|
if (duplicateOverriddenFieldPaths.size > 0) {
|
|
2277
2279
|
const duplicateOverriddenFieldErrorMessages = [];
|
|
2278
2280
|
for (const fieldPath of duplicateOverriddenFieldPaths) {
|
|
2279
|
-
const sourceSubgraphNames = (0,
|
|
2281
|
+
const sourceSubgraphNames = (0, utils_5.getOrThrowError)(overrideSourceSubgraphNamesByFieldPath, fieldPath, 'overrideSourceSubgraphNamesByFieldPath');
|
|
2280
2282
|
duplicateOverriddenFieldErrorMessages.push((0, errors_1.duplicateOverriddenFieldErrorMessage)(fieldPath, sourceSubgraphNames));
|
|
2281
2283
|
}
|
|
2282
2284
|
allErrors.push((0, errors_1.duplicateOverriddenFieldsError)(duplicateOverriddenFieldErrorMessages));
|
|
@@ -2284,17 +2286,13 @@ function batchNormalize(subgraphs) {
|
|
|
2284
2286
|
allErrors.push(...validationErrors);
|
|
2285
2287
|
if (allErrors.length > 0) {
|
|
2286
2288
|
return {
|
|
2287
|
-
authorizationDataByParentTypeName,
|
|
2288
|
-
concreteTypeNamesByAbstractTypeName,
|
|
2289
|
-
entityDataByTypeName,
|
|
2290
2289
|
errors: allErrors,
|
|
2291
|
-
|
|
2292
|
-
internalGraph,
|
|
2290
|
+
success: false,
|
|
2293
2291
|
warnings,
|
|
2294
2292
|
};
|
|
2295
2293
|
}
|
|
2296
2294
|
for (const [targetSubgraphName, overridesData] of allOverridesByTargetSubgraphName) {
|
|
2297
|
-
const internalSubgraph = (0,
|
|
2295
|
+
const internalSubgraph = (0, utils_5.getOrThrowError)(internalSubgraphBySubgraphName, targetSubgraphName, 'internalSubgraphBySubgraphName');
|
|
2298
2296
|
internalSubgraph.overriddenFieldNamesByParentTypeName = overridesData;
|
|
2299
2297
|
for (const [parentTypeName, fieldNames] of overridesData) {
|
|
2300
2298
|
const configurationData = internalSubgraph.configurationDataByTypeName.get(parentTypeName);
|
|
@@ -2313,6 +2311,7 @@ function batchNormalize(subgraphs) {
|
|
|
2313
2311
|
entityDataByTypeName,
|
|
2314
2312
|
internalSubgraphBySubgraphName: internalSubgraphBySubgraphName,
|
|
2315
2313
|
internalGraph,
|
|
2314
|
+
success: true,
|
|
2316
2315
|
warnings,
|
|
2317
2316
|
};
|
|
2318
2317
|
}
|