@wundergraph/composition 0.47.1 → 0.47.2
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/index.d.ts +7 -2
- package/dist/index.js +7 -2
- package/dist/index.js.map +1 -1
- package/dist/normalization/types.d.ts +3 -3
- package/dist/schema-building/ast.d.ts +1 -1
- package/dist/schema-building/utils.d.ts +7 -6
- package/dist/schema-building/utils.js +6 -37
- package/dist/schema-building/utils.js.map +1 -1
- package/dist/subgraph/types.d.ts +3 -3
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/utils/composition-version.js +1 -1
- package/dist/utils/params.d.ts +12 -0
- package/dist/utils/params.js +3 -0
- package/dist/utils/params.js.map +1 -0
- package/dist/utils/utils.d.ts +4 -2
- package/dist/utils/utils.js +12 -3
- package/dist/utils/utils.js.map +1 -1
- package/dist/v1/constants/constants.d.ts +7 -0
- package/dist/v1/constants/constants.js +60 -0
- package/dist/v1/constants/constants.js.map +1 -0
- package/dist/v1/constants/directive-definitions.d.ts +30 -0
- package/dist/v1/{utils/constants.js → constants/directive-definitions.js} +186 -454
- package/dist/v1/constants/directive-definitions.js.map +1 -0
- package/dist/v1/{utils/integer-constants.js → constants/integers.js} +1 -1
- package/dist/v1/constants/integers.js.map +1 -0
- package/dist/v1/constants/non-directive-definitions.d.ts +9 -0
- package/dist/v1/constants/non-directive-definitions.js +166 -0
- package/dist/v1/constants/non-directive-definitions.js.map +1 -0
- package/dist/v1/constants/strings.d.ts +11 -0
- package/dist/v1/constants/strings.js +82 -0
- package/dist/v1/constants/strings.js.map +1 -0
- package/dist/v1/constants/type-nodes.d.ts +3 -0
- package/dist/v1/constants/type-nodes.js +15 -0
- package/dist/v1/constants/type-nodes.js.map +1 -0
- package/dist/v1/federation/federation-factory.d.ts +11 -11
- package/dist/v1/federation/federation-factory.js +257 -147
- package/dist/v1/federation/federation-factory.js.map +1 -1
- package/dist/v1/federation/params.d.ts +7 -2
- package/dist/v1/federation/utils.js +1 -1
- package/dist/v1/federation/utils.js.map +1 -1
- package/dist/v1/normalization/directive-definition-data.js +55 -53
- package/dist/v1/normalization/directive-definition-data.js.map +1 -1
- package/dist/v1/normalization/normalization-factory.d.ts +9 -8
- package/dist/v1/normalization/normalization-factory.js +251 -239
- package/dist/v1/normalization/normalization-factory.js.map +1 -1
- package/dist/v1/normalization/types.d.ts +9 -1
- package/dist/v1/normalization/utils.js +1 -1
- package/dist/v1/normalization/utils.js.map +1 -1
- package/dist/v1/normalization/walkers.js +21 -38
- package/dist/v1/normalization/walkers.js.map +1 -1
- package/dist/v1/utils/utils.js +15 -6
- package/dist/v1/utils/utils.js.map +1 -1
- package/package.json +2 -2
- package/dist/v1/utils/constants.d.ts +0 -50
- package/dist/v1/utils/constants.js.map +0 -1
- package/dist/v1/utils/integer-constants.js.map +0 -1
- package/dist/v1/utils/string-constants.d.ts +0 -7
- package/dist/v1/utils/string-constants.js +0 -41
- package/dist/v1/utils/string-constants.js.map +0 -1
- /package/dist/v1/{utils/integer-constants.d.ts → constants/integers.d.ts} +0 -0
|
@@ -7,10 +7,10 @@ exports.batchNormalize = batchNormalize;
|
|
|
7
7
|
const graphql_1 = require("graphql");
|
|
8
8
|
const utils_1 = require("../../ast/utils");
|
|
9
9
|
const utils_2 = require("./utils");
|
|
10
|
-
const constants_1 = require("../
|
|
10
|
+
const constants_1 = require("../constants/constants");
|
|
11
11
|
const utils_3 = require("../utils/utils");
|
|
12
12
|
const errors_1 = require("../../errors/errors");
|
|
13
|
-
const
|
|
13
|
+
const strings_1 = require("../constants/strings");
|
|
14
14
|
const buildASTSchema_1 = require("../../buildASTSchema/buildASTSchema");
|
|
15
15
|
const merge_1 = require("@graphql-tools/merge");
|
|
16
16
|
const subgraph_1 = require("../subgraph/subgraph");
|
|
@@ -20,11 +20,12 @@ const types_1 = require("../../schema-building/types");
|
|
|
20
20
|
const utils_4 = require("../../schema-building/utils");
|
|
21
21
|
const ast_1 = require("../../schema-building/ast");
|
|
22
22
|
const graph_1 = require("../../resolvability-graph/graph");
|
|
23
|
-
const
|
|
24
|
-
const
|
|
25
|
-
const
|
|
23
|
+
const integers_1 = require("../constants/integers");
|
|
24
|
+
const string_constants_1 = require("../../utils/string-constants");
|
|
25
|
+
const integer_constants_1 = require("../../utils/integer-constants");
|
|
26
26
|
const utils_5 = require("../../utils/utils");
|
|
27
27
|
const utils_6 = require("../../router-configuration/utils");
|
|
28
|
+
const non_directive_definitions_1 = require("../constants/non-directive-definitions");
|
|
28
29
|
function normalizeSubgraphFromString(subgraphSDL, noLocation = true) {
|
|
29
30
|
const { error, documentNode } = (0, utils_1.safeParse)(subgraphSDL, noLocation);
|
|
30
31
|
if (error || !documentNode) {
|
|
@@ -43,10 +44,10 @@ class NormalizationFactory {
|
|
|
43
44
|
concreteTypeNamesByAbstractTypeName = new Map();
|
|
44
45
|
conditionalFieldDataByCoords = new Map();
|
|
45
46
|
configurationDataByTypeName = new Map();
|
|
46
|
-
|
|
47
|
+
customDirectiveDefinitionByName = new Map();
|
|
47
48
|
definedDirectiveNames = new Set();
|
|
48
|
-
|
|
49
|
-
|
|
49
|
+
directiveDefinitionByName = new Map();
|
|
50
|
+
directiveDefinitionDataByName = (0, utils_2.initializeDirectiveDefinitionDatas)();
|
|
50
51
|
doesParentRequireFetchReasons = false;
|
|
51
52
|
edfsDirectiveReferences = new Set();
|
|
52
53
|
errors = new Array();
|
|
@@ -83,16 +84,13 @@ class NormalizationFactory {
|
|
|
83
84
|
usesEdfsNatsStreamConfiguration = false;
|
|
84
85
|
warnings = [];
|
|
85
86
|
constructor(internalGraph, subgraphName) {
|
|
86
|
-
|
|
87
|
-
this.directiveDefinitionByDirectiveName.set(baseDirectiveName, baseDirectiveDefinition);
|
|
88
|
-
}
|
|
89
|
-
this.subgraphName = subgraphName || string_constants_2.NOT_APPLICABLE;
|
|
87
|
+
this.subgraphName = subgraphName || string_constants_1.NOT_APPLICABLE;
|
|
90
88
|
this.internalGraph = internalGraph;
|
|
91
89
|
this.internalGraph.setSubgraphName(this.subgraphName);
|
|
92
90
|
this.schemaData = {
|
|
93
91
|
directivesByDirectiveName: new Map(),
|
|
94
92
|
kind: graphql_1.Kind.SCHEMA_DEFINITION,
|
|
95
|
-
name:
|
|
93
|
+
name: string_constants_1.SCHEMA,
|
|
96
94
|
operationTypes: new Map(),
|
|
97
95
|
};
|
|
98
96
|
}
|
|
@@ -120,7 +118,7 @@ class NormalizationFactory {
|
|
|
120
118
|
}
|
|
121
119
|
}
|
|
122
120
|
isTypeNameRootType(typeName) {
|
|
123
|
-
return
|
|
121
|
+
return string_constants_1.ROOT_TYPE_NAMES.has(typeName) || this.operationTypeNodeByTypeName.has(typeName);
|
|
124
122
|
}
|
|
125
123
|
isArgumentValueValid(typeNode, argumentValue) {
|
|
126
124
|
if (argumentValue.kind === graphql_1.Kind.NULL) {
|
|
@@ -141,37 +139,37 @@ class NormalizationFactory {
|
|
|
141
139
|
}
|
|
142
140
|
case graphql_1.Kind.NAMED_TYPE: {
|
|
143
141
|
switch (typeNode.name.value) {
|
|
144
|
-
case
|
|
142
|
+
case string_constants_1.BOOLEAN_SCALAR: {
|
|
145
143
|
return argumentValue.kind === graphql_1.Kind.BOOLEAN;
|
|
146
144
|
}
|
|
147
|
-
case
|
|
145
|
+
case string_constants_1.FLOAT_SCALAR: {
|
|
148
146
|
return argumentValue.kind === graphql_1.Kind.FLOAT || argumentValue.kind === graphql_1.Kind.INT;
|
|
149
147
|
}
|
|
150
|
-
case
|
|
148
|
+
case string_constants_1.ID_SCALAR: {
|
|
151
149
|
return argumentValue.kind === graphql_1.Kind.STRING || argumentValue.kind === graphql_1.Kind.INT;
|
|
152
150
|
}
|
|
153
|
-
case
|
|
151
|
+
case string_constants_1.INT_SCALAR: {
|
|
154
152
|
return argumentValue.kind === graphql_1.Kind.INT;
|
|
155
153
|
}
|
|
156
|
-
case
|
|
154
|
+
case string_constants_1.FIELD_SET_SCALAR:
|
|
157
155
|
// intentional fallthrough
|
|
158
|
-
case
|
|
156
|
+
case string_constants_1.SCOPE_SCALAR:
|
|
159
157
|
// intentional fallthrough
|
|
160
|
-
case
|
|
158
|
+
case string_constants_1.STRING_SCALAR: {
|
|
161
159
|
return argumentValue.kind === graphql_1.Kind.STRING;
|
|
162
160
|
}
|
|
163
|
-
case
|
|
161
|
+
case string_constants_1.LINK_IMPORT: {
|
|
164
162
|
return true;
|
|
165
163
|
}
|
|
166
|
-
case
|
|
164
|
+
case string_constants_1.LINK_PURPOSE: {
|
|
167
165
|
if (argumentValue.kind !== graphql_1.Kind.ENUM) {
|
|
168
166
|
return false;
|
|
169
167
|
}
|
|
170
|
-
return argumentValue.value ===
|
|
168
|
+
return argumentValue.value === string_constants_1.SECURITY || argumentValue.value === string_constants_1.EXECUTION;
|
|
171
169
|
}
|
|
172
|
-
case
|
|
170
|
+
case string_constants_1.SUBSCRIPTION_FIELD_CONDITION:
|
|
173
171
|
// intentional fallthrough
|
|
174
|
-
case
|
|
172
|
+
case string_constants_1.SUBSCRIPTION_FILTER_CONDITION:
|
|
175
173
|
return argumentValue.kind === graphql_1.Kind.OBJECT;
|
|
176
174
|
default: {
|
|
177
175
|
const parentData = this.parentDefinitionDataByTypeName.get(typeNode.name.value);
|
|
@@ -190,7 +188,7 @@ class NormalizationFactory {
|
|
|
190
188
|
if (!enumValue) {
|
|
191
189
|
return false;
|
|
192
190
|
}
|
|
193
|
-
return !enumValue.directivesByDirectiveName.has(
|
|
191
|
+
return !enumValue.directivesByDirectiveName.has(string_constants_1.INACCESSIBLE);
|
|
194
192
|
}
|
|
195
193
|
if (parentData.kind !== graphql_1.Kind.INPUT_OBJECT_TYPE_DEFINITION) {
|
|
196
194
|
return false;
|
|
@@ -206,26 +204,26 @@ class NormalizationFactory {
|
|
|
206
204
|
}
|
|
207
205
|
}
|
|
208
206
|
handleFieldInheritableDirectives({ directivesByDirectiveName, fieldName, inheritedDirectiveNames, parentData, }) {
|
|
209
|
-
if (this.doesParentRequireFetchReasons && !directivesByDirectiveName.has(
|
|
210
|
-
directivesByDirectiveName.set(
|
|
211
|
-
inheritedDirectiveNames.add(
|
|
207
|
+
if (this.doesParentRequireFetchReasons && !directivesByDirectiveName.has(string_constants_1.REQUIRE_FETCH_REASONS)) {
|
|
208
|
+
directivesByDirectiveName.set(string_constants_1.REQUIRE_FETCH_REASONS, [(0, utils_5.generateSimpleDirective)(string_constants_1.REQUIRE_FETCH_REASONS)]);
|
|
209
|
+
inheritedDirectiveNames.add(string_constants_1.REQUIRE_FETCH_REASONS);
|
|
212
210
|
}
|
|
213
|
-
if (this.doesParentRequireFetchReasons || directivesByDirectiveName.has(
|
|
211
|
+
if (this.doesParentRequireFetchReasons || directivesByDirectiveName.has(string_constants_1.REQUIRE_FETCH_REASONS)) {
|
|
214
212
|
parentData.requireFetchReasonsFieldNames.add(fieldName);
|
|
215
213
|
}
|
|
216
214
|
if (!(0, utils_3.isObjectDefinitionData)(parentData)) {
|
|
217
215
|
return;
|
|
218
216
|
}
|
|
219
|
-
if (this.isParentObjectExternal && !directivesByDirectiveName.has(
|
|
220
|
-
directivesByDirectiveName.set(
|
|
221
|
-
inheritedDirectiveNames.add(
|
|
217
|
+
if (this.isParentObjectExternal && !directivesByDirectiveName.has(string_constants_1.EXTERNAL)) {
|
|
218
|
+
directivesByDirectiveName.set(string_constants_1.EXTERNAL, [(0, utils_5.generateSimpleDirective)(string_constants_1.EXTERNAL)]);
|
|
219
|
+
inheritedDirectiveNames.add(string_constants_1.EXTERNAL);
|
|
222
220
|
}
|
|
223
|
-
if (directivesByDirectiveName.has(
|
|
221
|
+
if (directivesByDirectiveName.has(string_constants_1.EXTERNAL)) {
|
|
224
222
|
this.unvalidatedExternalFieldCoords.add(`${parentData.name}.${fieldName}`);
|
|
225
223
|
}
|
|
226
|
-
if (this.isParentObjectShareable && !directivesByDirectiveName.has(
|
|
227
|
-
directivesByDirectiveName.set(
|
|
228
|
-
inheritedDirectiveNames.add(
|
|
224
|
+
if (this.isParentObjectShareable && !directivesByDirectiveName.has(string_constants_1.SHAREABLE)) {
|
|
225
|
+
directivesByDirectiveName.set(string_constants_1.SHAREABLE, [(0, utils_5.generateSimpleDirective)(string_constants_1.SHAREABLE)]);
|
|
226
|
+
inheritedDirectiveNames.add(string_constants_1.SHAREABLE);
|
|
229
227
|
}
|
|
230
228
|
}
|
|
231
229
|
extractDirectives(node, directivesByDirectiveName) {
|
|
@@ -237,7 +235,7 @@ class NormalizationFactory {
|
|
|
237
235
|
for (const directiveNode of node.directives) {
|
|
238
236
|
const directiveName = directiveNode.name.value;
|
|
239
237
|
// Don't create pointless repetitions of @shareable
|
|
240
|
-
if (directiveName ===
|
|
238
|
+
if (directiveName === string_constants_1.SHAREABLE) {
|
|
241
239
|
(0, utils_5.getValueOrDefault)(directivesByDirectiveName, directiveName, () => [directiveNode]);
|
|
242
240
|
}
|
|
243
241
|
else {
|
|
@@ -246,23 +244,23 @@ class NormalizationFactory {
|
|
|
246
244
|
if (!isCompositeKind) {
|
|
247
245
|
continue;
|
|
248
246
|
}
|
|
249
|
-
this.doesParentRequireFetchReasons ||= directiveName ===
|
|
247
|
+
this.doesParentRequireFetchReasons ||= directiveName === string_constants_1.REQUIRE_FETCH_REASONS;
|
|
250
248
|
if (!isObjectKind) {
|
|
251
249
|
continue;
|
|
252
250
|
}
|
|
253
|
-
this.isParentObjectExternal ||= directiveName ===
|
|
254
|
-
this.isParentObjectShareable ||= directiveName ===
|
|
251
|
+
this.isParentObjectExternal ||= directiveName === string_constants_1.EXTERNAL;
|
|
252
|
+
this.isParentObjectShareable ||= directiveName === string_constants_1.SHAREABLE;
|
|
255
253
|
}
|
|
256
254
|
return directivesByDirectiveName;
|
|
257
255
|
}
|
|
258
256
|
validateDirective({ data, definitionData, directiveCoords, directiveNode, errorMessages, requiredArgumentNames, }) {
|
|
259
257
|
const directiveName = directiveNode.name.value;
|
|
260
258
|
const parentTypeName = data.kind === graphql_1.Kind.FIELD_DEFINITION ? data.renamedParentTypeName || data.originalParentTypeName : data.name;
|
|
261
|
-
const isAuthenticated = directiveName ===
|
|
259
|
+
const isAuthenticated = directiveName === string_constants_1.AUTHENTICATED;
|
|
262
260
|
const isField = (0, utils_4.isFieldData)(data);
|
|
263
|
-
const isOverride = directiveName ===
|
|
264
|
-
const isRequiresScopes = directiveName ===
|
|
265
|
-
const isSemanticNonNull = directiveName ===
|
|
261
|
+
const isOverride = directiveName === string_constants_1.OVERRIDE;
|
|
262
|
+
const isRequiresScopes = directiveName === string_constants_1.REQUIRES_SCOPES;
|
|
263
|
+
const isSemanticNonNull = directiveName === string_constants_1.SEMANTIC_NON_NULL;
|
|
266
264
|
if (!directiveNode.arguments || directiveNode.arguments.length < 1) {
|
|
267
265
|
if (definitionData.requiredArgumentNames.size > 0) {
|
|
268
266
|
errorMessages.push((0, errors_1.undefinedRequiredArgumentsErrorMessage)(directiveName, requiredArgumentNames, []));
|
|
@@ -325,7 +323,7 @@ class NormalizationFactory {
|
|
|
325
323
|
});
|
|
326
324
|
continue;
|
|
327
325
|
}
|
|
328
|
-
if (!isRequiresScopes || argumentName !==
|
|
326
|
+
if (!isRequiresScopes || argumentName !== string_constants_1.SCOPES) {
|
|
329
327
|
continue;
|
|
330
328
|
}
|
|
331
329
|
this.extractRequiredScopes({
|
|
@@ -363,7 +361,7 @@ class NormalizationFactory {
|
|
|
363
361
|
validateDirectives(data, directiveCoords) {
|
|
364
362
|
const undefinedDirectiveNames = new Set();
|
|
365
363
|
for (const [directiveName, directiveNodes] of data.directivesByDirectiveName) {
|
|
366
|
-
const definitionData = this.
|
|
364
|
+
const definitionData = this.directiveDefinitionDataByName.get(directiveName);
|
|
367
365
|
if (!definitionData) {
|
|
368
366
|
if (!undefinedDirectiveNames.has(directiveName)) {
|
|
369
367
|
this.errors.push((0, errors_1.undefinedDirectiveError)(directiveName, directiveCoords));
|
|
@@ -445,7 +443,7 @@ class NormalizationFactory {
|
|
|
445
443
|
* 2. It's a V2 subgraph (but extends is temporarily propagated to handle @external key fields)
|
|
446
444
|
* 3. And (of course) if @extends isn't defined at all
|
|
447
445
|
*/
|
|
448
|
-
if (isRootType || !directivesByDirectiveName.has(
|
|
446
|
+
if (isRootType || !directivesByDirectiveName.has(string_constants_1.EXTENDS)) {
|
|
449
447
|
return types_1.ExtensionType.NONE;
|
|
450
448
|
}
|
|
451
449
|
// If a V1 non-root Object defines @extends, it is considered an extension across subgraphs.
|
|
@@ -484,14 +482,14 @@ class NormalizationFactory {
|
|
|
484
482
|
};
|
|
485
483
|
for (const argument of directiveNode.arguments) {
|
|
486
484
|
switch (argument.name.value) {
|
|
487
|
-
case
|
|
485
|
+
case string_constants_1.PROPAGATE: {
|
|
488
486
|
if (argument.value.kind != graphql_1.Kind.BOOLEAN) {
|
|
489
487
|
return;
|
|
490
488
|
}
|
|
491
489
|
configureDescriptionData.propagate = argument.value.value;
|
|
492
490
|
break;
|
|
493
491
|
}
|
|
494
|
-
case
|
|
492
|
+
case string_constants_1.DESCRIPTION_OVERRIDE: {
|
|
495
493
|
if (argument.value.kind != graphql_1.Kind.STRING) {
|
|
496
494
|
return;
|
|
497
495
|
}
|
|
@@ -509,7 +507,7 @@ class NormalizationFactory {
|
|
|
509
507
|
data.configureDescriptionDataBySubgraphName.set(this.subgraphName, configureDescriptionData);
|
|
510
508
|
}
|
|
511
509
|
extractConfigureDescriptionsData(data) {
|
|
512
|
-
const configureDescriptionNodes = data.directivesByDirectiveName.get(
|
|
510
|
+
const configureDescriptionNodes = data.directivesByDirectiveName.get(string_constants_1.CONFIGURE_DESCRIPTION);
|
|
513
511
|
if (configureDescriptionNodes && configureDescriptionNodes.length == 1) {
|
|
514
512
|
this.extractConfigureDescriptionData(data, configureDescriptionNodes[0]);
|
|
515
513
|
}
|
|
@@ -538,8 +536,8 @@ class NormalizationFactory {
|
|
|
538
536
|
this.extractImplementedInterfaceTypeNames(node, data.implementedInterfaceTypeNames);
|
|
539
537
|
data.description ||= (0, utils_1.formatDescription)('description' in node ? node.description : undefined);
|
|
540
538
|
this.extractConfigureDescriptionsData(data);
|
|
541
|
-
data.isEntity ||= data.directivesByDirectiveName.has(
|
|
542
|
-
data.isInaccessible ||= data.directivesByDirectiveName.has(
|
|
539
|
+
data.isEntity ||= data.directivesByDirectiveName.has(string_constants_1.KEY);
|
|
540
|
+
data.isInaccessible ||= data.directivesByDirectiveName.has(string_constants_1.INACCESSIBLE);
|
|
543
541
|
data.subgraphNames.add(this.subgraphName);
|
|
544
542
|
}
|
|
545
543
|
addConcreteTypeNamesForImplementedInterfaces(interfaceTypeNames, concreteTypeName) {
|
|
@@ -604,7 +602,7 @@ class NormalizationFactory {
|
|
|
604
602
|
if (handledLocations.has(locationName)) {
|
|
605
603
|
continue;
|
|
606
604
|
}
|
|
607
|
-
if (!
|
|
605
|
+
if (!string_constants_1.EXECUTABLE_DIRECTIVE_LOCATIONS.has(locationName) && !strings_1.TYPE_SYSTEM_DIRECTIVE_LOCATIONS.has(locationName)) {
|
|
608
606
|
errorMessages.push((0, errors_1.invalidDirectiveDefinitionLocationErrorMessage)(locationName));
|
|
609
607
|
handledLocations.add(locationName);
|
|
610
608
|
continue;
|
|
@@ -662,18 +660,23 @@ class NormalizationFactory {
|
|
|
662
660
|
return false;
|
|
663
661
|
}
|
|
664
662
|
this.definedDirectiveNames.add(name);
|
|
665
|
-
this.directiveDefinitionByDirectiveName.set(name, node);
|
|
666
663
|
// Normalize federation directives by replacing them with predefined definitions
|
|
667
|
-
|
|
664
|
+
const definition = constants_1.V2_DIRECTIVE_DEFINITION_BY_DIRECTIVE_NAME.get(name);
|
|
665
|
+
// Add the V2 directive definitions regardless of use so the subgraph can be recognised as a V2 subgraph.
|
|
666
|
+
if (definition) {
|
|
667
|
+
this.directiveDefinitionByName.set(name, definition);
|
|
668
|
+
// Uses of the directive also set this boolean in the walker.
|
|
668
669
|
this.isSubgraphVersionTwo = true;
|
|
669
670
|
return false;
|
|
670
671
|
}
|
|
671
|
-
if
|
|
672
|
+
// Other known directives will only be added if they are used.
|
|
673
|
+
if (constants_1.DIRECTIVE_DEFINITION_BY_NAME.has(name)) {
|
|
672
674
|
return false;
|
|
673
675
|
}
|
|
676
|
+
this.directiveDefinitionByName.set(name, node);
|
|
674
677
|
const errorMessages = [];
|
|
675
678
|
const { argumentTypeNodeByName, optionalArgumentNames, requiredArgumentNames } = this.extractArgumentData(node.arguments, errorMessages);
|
|
676
|
-
this.
|
|
679
|
+
this.directiveDefinitionDataByName.set(name, {
|
|
677
680
|
argumentTypeNodeByName: argumentTypeNodeByName,
|
|
678
681
|
isRepeatable: node.repeatable,
|
|
679
682
|
locations: this.extractDirectiveLocations(node, errorMessages),
|
|
@@ -701,7 +704,7 @@ class NormalizationFactory {
|
|
|
701
704
|
]),
|
|
702
705
|
federatedCoords: `${parentTypeName}.${name}`,
|
|
703
706
|
inheritedDirectiveNames,
|
|
704
|
-
isInaccessible: directivesByDirectiveName.has(
|
|
707
|
+
isInaccessible: directivesByDirectiveName.has(string_constants_1.INACCESSIBLE),
|
|
705
708
|
isShareableBySubgraphName: new Map([[this.subgraphName, isShareable]]),
|
|
706
709
|
kind: graphql_1.Kind.FIELD_DEFINITION,
|
|
707
710
|
name,
|
|
@@ -732,7 +735,7 @@ class NormalizationFactory {
|
|
|
732
735
|
? `${originalParentTypeName}${fieldName ? `.${fieldName}` : ''}(${name}: ...)`
|
|
733
736
|
: `${originalParentTypeName}.${name}`;
|
|
734
737
|
if (node.defaultValue && !(0, utils_4.areDefaultValuesCompatible)(node.type, node.defaultValue)) {
|
|
735
|
-
this.errors.push((0, errors_1.incompatibleInputValueDefaultValueTypeError)((isArgument ?
|
|
738
|
+
this.errors.push((0, errors_1.incompatibleInputValueDefaultValueTypeError)((isArgument ? string_constants_1.ARGUMENT : string_constants_1.INPUT_FIELD) + ` "${name}"`, originalCoords, (0, merge_1.printTypeNode)(node.type), (0, graphql_1.print)(node.defaultValue)));
|
|
736
739
|
}
|
|
737
740
|
const federatedCoords = isArgument
|
|
738
741
|
? `${federatedParentTypeName}${fieldName ? `.${fieldName}` : ''}(${name}: ...)`
|
|
@@ -788,8 +791,8 @@ class NormalizationFactory {
|
|
|
788
791
|
extensionType,
|
|
789
792
|
fieldDataByName: new Map(),
|
|
790
793
|
implementedInterfaceTypeNames: this.extractImplementedInterfaceTypeNames(node, new Set()),
|
|
791
|
-
isEntity: directivesByDirectiveName.has(
|
|
792
|
-
isInaccessible: directivesByDirectiveName.has(
|
|
794
|
+
isEntity: directivesByDirectiveName.has(string_constants_1.KEY),
|
|
795
|
+
isInaccessible: directivesByDirectiveName.has(string_constants_1.INACCESSIBLE),
|
|
793
796
|
kind: graphql_1.Kind.INTERFACE_TYPE_DEFINITION,
|
|
794
797
|
name: typeName,
|
|
795
798
|
node: (0, ast_1.getMutableInterfaceNode)(node.name),
|
|
@@ -808,11 +811,11 @@ class NormalizationFactory {
|
|
|
808
811
|
}
|
|
809
812
|
switch (operationTypeNode) {
|
|
810
813
|
case graphql_1.OperationTypeNode.MUTATION:
|
|
811
|
-
return
|
|
814
|
+
return string_constants_1.MUTATION;
|
|
812
815
|
case graphql_1.OperationTypeNode.SUBSCRIPTION:
|
|
813
|
-
return
|
|
816
|
+
return string_constants_1.SUBSCRIPTION;
|
|
814
817
|
default:
|
|
815
|
-
return
|
|
818
|
+
return string_constants_1.QUERY;
|
|
816
819
|
}
|
|
817
820
|
}
|
|
818
821
|
addInterfaceObjectFieldsByNode(node) {
|
|
@@ -838,13 +841,13 @@ class NormalizationFactory {
|
|
|
838
841
|
return;
|
|
839
842
|
}
|
|
840
843
|
this.updateCompositeOutputDataByNode(node, parentData, extensionType);
|
|
841
|
-
if (!directivesByDirectiveName.has(
|
|
844
|
+
if (!directivesByDirectiveName.has(string_constants_1.INTERFACE_OBJECT)) {
|
|
842
845
|
this.addConcreteTypeNamesForImplementedInterfaces(parentData.implementedInterfaceTypeNames, typeName);
|
|
843
846
|
}
|
|
844
847
|
return;
|
|
845
848
|
}
|
|
846
849
|
const implementedInterfaceTypeNames = this.extractImplementedInterfaceTypeNames(node, new Set());
|
|
847
|
-
if (!directivesByDirectiveName.has(
|
|
850
|
+
if (!directivesByDirectiveName.has(string_constants_1.INTERFACE_OBJECT)) {
|
|
848
851
|
this.addConcreteTypeNamesForImplementedInterfaces(implementedInterfaceTypeNames, typeName);
|
|
849
852
|
}
|
|
850
853
|
const newParentData = {
|
|
@@ -853,8 +856,8 @@ class NormalizationFactory {
|
|
|
853
856
|
extensionType,
|
|
854
857
|
fieldDataByName: new Map(),
|
|
855
858
|
implementedInterfaceTypeNames,
|
|
856
|
-
isEntity: directivesByDirectiveName.has(
|
|
857
|
-
isInaccessible: directivesByDirectiveName.has(
|
|
859
|
+
isEntity: directivesByDirectiveName.has(string_constants_1.KEY),
|
|
860
|
+
isInaccessible: directivesByDirectiveName.has(string_constants_1.INACCESSIBLE),
|
|
858
861
|
isRootType,
|
|
859
862
|
kind: graphql_1.Kind.OBJECT_TYPE_DEFINITION,
|
|
860
863
|
name: typeName,
|
|
@@ -880,7 +883,7 @@ class NormalizationFactory {
|
|
|
880
883
|
return;
|
|
881
884
|
}
|
|
882
885
|
this.setParentDataExtensionType(parentData, extensionType);
|
|
883
|
-
parentData.isInaccessible ||= directivesByDirectiveName.has(
|
|
886
|
+
parentData.isInaccessible ||= directivesByDirectiveName.has(string_constants_1.INACCESSIBLE);
|
|
884
887
|
parentData.subgraphNames.add(this.subgraphName);
|
|
885
888
|
parentData.description ||= (0, utils_1.formatDescription)('description' in node ? node.description : undefined);
|
|
886
889
|
this.extractConfigureDescriptionsData(parentData);
|
|
@@ -892,7 +895,7 @@ class NormalizationFactory {
|
|
|
892
895
|
directivesByDirectiveName,
|
|
893
896
|
extensionType,
|
|
894
897
|
enumValueDataByName: new Map(),
|
|
895
|
-
isInaccessible: directivesByDirectiveName.has(
|
|
898
|
+
isInaccessible: directivesByDirectiveName.has(string_constants_1.INACCESSIBLE),
|
|
896
899
|
kind: graphql_1.Kind.ENUM_TYPE_DEFINITION,
|
|
897
900
|
name: typeName,
|
|
898
901
|
node: (0, ast_1.getMutableEnumNode)(node.name),
|
|
@@ -911,21 +914,26 @@ class NormalizationFactory {
|
|
|
911
914
|
if (parentData) {
|
|
912
915
|
if (parentData.kind !== graphql_1.Kind.INPUT_OBJECT_TYPE_DEFINITION) {
|
|
913
916
|
this.errors.push((0, errors_1.multipleNamedTypeDefinitionError)(typeName, (0, utils_5.kindToNodeType)(parentData.kind), (0, utils_3.kindToConvertedTypeString)(node.kind)));
|
|
914
|
-
return
|
|
917
|
+
return {
|
|
918
|
+
success: false,
|
|
919
|
+
};
|
|
915
920
|
}
|
|
916
921
|
this.setParentDataExtensionType(parentData, extensionType);
|
|
917
|
-
parentData.isInaccessible ||= directivesByDirectiveName.has(
|
|
922
|
+
parentData.isInaccessible ||= directivesByDirectiveName.has(string_constants_1.INACCESSIBLE);
|
|
918
923
|
parentData.subgraphNames.add(this.subgraphName);
|
|
919
924
|
parentData.description ||= (0, utils_1.formatDescription)('description' in node ? node.description : undefined);
|
|
920
925
|
this.extractConfigureDescriptionsData(parentData);
|
|
921
|
-
return
|
|
926
|
+
return {
|
|
927
|
+
success: true,
|
|
928
|
+
data: parentData,
|
|
929
|
+
};
|
|
922
930
|
}
|
|
923
931
|
const newParentData = {
|
|
924
932
|
configureDescriptionDataBySubgraphName: new Map(),
|
|
925
933
|
directivesByDirectiveName,
|
|
926
934
|
extensionType,
|
|
927
935
|
inputValueDataByName: new Map(),
|
|
928
|
-
isInaccessible: directivesByDirectiveName.has(
|
|
936
|
+
isInaccessible: directivesByDirectiveName.has(string_constants_1.INACCESSIBLE),
|
|
929
937
|
kind: graphql_1.Kind.INPUT_OBJECT_TYPE_DEFINITION,
|
|
930
938
|
name: typeName,
|
|
931
939
|
node: (0, ast_1.getMutableInputObjectNode)(node.name),
|
|
@@ -935,6 +943,10 @@ class NormalizationFactory {
|
|
|
935
943
|
};
|
|
936
944
|
this.extractConfigureDescriptionsData(newParentData);
|
|
937
945
|
this.parentDefinitionDataByTypeName.set(typeName, newParentData);
|
|
946
|
+
return {
|
|
947
|
+
success: true,
|
|
948
|
+
data: newParentData,
|
|
949
|
+
};
|
|
938
950
|
}
|
|
939
951
|
upsertScalarByNode(node, isRealExtension = false) {
|
|
940
952
|
const typeName = node.name.value;
|
|
@@ -1036,7 +1048,7 @@ class NormalizationFactory {
|
|
|
1036
1048
|
// full validation happens elsewhere
|
|
1037
1049
|
let keyNumber = 0;
|
|
1038
1050
|
for (const directive of node.directives) {
|
|
1039
|
-
if (directive.name.value !==
|
|
1051
|
+
if (directive.name.value !== string_constants_1.KEY) {
|
|
1040
1052
|
continue;
|
|
1041
1053
|
}
|
|
1042
1054
|
keyNumber += 1;
|
|
@@ -1046,13 +1058,13 @@ class NormalizationFactory {
|
|
|
1046
1058
|
let rawFieldSet;
|
|
1047
1059
|
let isUnresolvable = false;
|
|
1048
1060
|
for (const arg of directive.arguments) {
|
|
1049
|
-
if (arg.name.value ===
|
|
1061
|
+
if (arg.name.value === string_constants_1.RESOLVABLE) {
|
|
1050
1062
|
if (arg.value.kind === graphql_1.Kind.BOOLEAN && !arg.value.value) {
|
|
1051
1063
|
isUnresolvable = true;
|
|
1052
1064
|
}
|
|
1053
1065
|
continue;
|
|
1054
1066
|
}
|
|
1055
|
-
if (arg.name.value !==
|
|
1067
|
+
if (arg.name.value !== string_constants_1.FIELDS) {
|
|
1056
1068
|
rawFieldSet = undefined;
|
|
1057
1069
|
break;
|
|
1058
1070
|
}
|
|
@@ -1067,7 +1079,7 @@ class NormalizationFactory {
|
|
|
1067
1079
|
}
|
|
1068
1080
|
const { error, documentNode } = (0, utils_1.safeParse)('{' + rawFieldSet + '}');
|
|
1069
1081
|
if (error || !documentNode) {
|
|
1070
|
-
this.errors.push((0, errors_1.invalidDirectiveError)(
|
|
1082
|
+
this.errors.push((0, errors_1.invalidDirectiveError)(string_constants_1.KEY, parentTypeName, (0, utils_5.numberToOrdinal)(keyNumber), [
|
|
1071
1083
|
(0, errors_1.unparsableFieldSetErrorMessage)(rawFieldSet, error),
|
|
1072
1084
|
]));
|
|
1073
1085
|
continue;
|
|
@@ -1373,7 +1385,7 @@ class NormalizationFactory {
|
|
|
1373
1385
|
* For V2 subgraphs, this will propagate as an error; for V1 subgraphs, this will propagate as a warning.
|
|
1374
1386
|
* */
|
|
1375
1387
|
if (errorMessages.length > 0) {
|
|
1376
|
-
allErrorMessages.push(` On field "${fieldCoords}":\n -` + errorMessages.join(
|
|
1388
|
+
allErrorMessages.push(` On field "${fieldCoords}":\n -` + errorMessages.join(string_constants_1.HYPHEN_JOIN));
|
|
1377
1389
|
continue;
|
|
1378
1390
|
}
|
|
1379
1391
|
if (configuration) {
|
|
@@ -1392,7 +1404,7 @@ class NormalizationFactory {
|
|
|
1392
1404
|
if (data.implementedInterfaceTypeNames.size < 1) {
|
|
1393
1405
|
return;
|
|
1394
1406
|
}
|
|
1395
|
-
const isParentInaccessible = data.directivesByDirectiveName.has(
|
|
1407
|
+
const isParentInaccessible = data.directivesByDirectiveName.has(string_constants_1.INACCESSIBLE);
|
|
1396
1408
|
const implementationErrorsMap = new Map();
|
|
1397
1409
|
const invalidImplementationTypeStringByTypeName = new Map();
|
|
1398
1410
|
let doesInterfaceImplementItself = false;
|
|
@@ -1537,7 +1549,7 @@ class NormalizationFactory {
|
|
|
1537
1549
|
}
|
|
1538
1550
|
}
|
|
1539
1551
|
}
|
|
1540
|
-
const levelsArg = directiveNode.arguments?.find((arg) => arg.name.value ===
|
|
1552
|
+
const levelsArg = directiveNode.arguments?.find((arg) => arg.name.value === string_constants_1.LEVELS);
|
|
1541
1553
|
if (!levelsArg || levelsArg.value.kind !== graphql_1.Kind.LIST) {
|
|
1542
1554
|
// Should never happen because the argument will have just been validated.
|
|
1543
1555
|
errorMessages.push(errors_1.semanticNonNullArgumentErrorMessage);
|
|
@@ -1589,19 +1601,19 @@ class NormalizationFactory {
|
|
|
1589
1601
|
}
|
|
1590
1602
|
getKafkaPublishConfiguration(directive, argumentDataByArgumentName, fieldName, errorMessages) {
|
|
1591
1603
|
const topics = [];
|
|
1592
|
-
let providerId =
|
|
1604
|
+
let providerId = string_constants_1.DEFAULT_EDFS_PROVIDER_ID;
|
|
1593
1605
|
for (const argumentNode of directive.arguments || []) {
|
|
1594
1606
|
switch (argumentNode.name.value) {
|
|
1595
|
-
case
|
|
1607
|
+
case string_constants_1.TOPIC: {
|
|
1596
1608
|
if (argumentNode.value.kind !== graphql_1.Kind.STRING || argumentNode.value.value.length < 1) {
|
|
1597
|
-
errorMessages.push((0, errors_1.invalidEventSubjectErrorMessage)(
|
|
1609
|
+
errorMessages.push((0, errors_1.invalidEventSubjectErrorMessage)(string_constants_1.TOPIC));
|
|
1598
1610
|
continue;
|
|
1599
1611
|
}
|
|
1600
1612
|
(0, utils_2.validateArgumentTemplateReferences)(argumentNode.value.value, argumentDataByArgumentName, errorMessages);
|
|
1601
1613
|
topics.push(argumentNode.value.value);
|
|
1602
1614
|
break;
|
|
1603
1615
|
}
|
|
1604
|
-
case
|
|
1616
|
+
case string_constants_1.PROVIDER_ID: {
|
|
1605
1617
|
if (argumentNode.value.kind !== graphql_1.Kind.STRING || argumentNode.value.value.length < 1) {
|
|
1606
1618
|
errorMessages.push(errors_1.invalidEventProviderIdErrorMessage);
|
|
1607
1619
|
continue;
|
|
@@ -1614,22 +1626,22 @@ class NormalizationFactory {
|
|
|
1614
1626
|
if (errorMessages.length > 0) {
|
|
1615
1627
|
return;
|
|
1616
1628
|
}
|
|
1617
|
-
return { fieldName, providerId, providerType:
|
|
1629
|
+
return { fieldName, providerId, providerType: string_constants_1.PROVIDER_TYPE_KAFKA, topics, type: string_constants_1.PUBLISH };
|
|
1618
1630
|
}
|
|
1619
1631
|
getKafkaSubscribeConfiguration(directive, argumentDataByArgumentName, fieldName, errorMessages) {
|
|
1620
1632
|
const topics = [];
|
|
1621
|
-
let providerId =
|
|
1633
|
+
let providerId = string_constants_1.DEFAULT_EDFS_PROVIDER_ID;
|
|
1622
1634
|
for (const argumentNode of directive.arguments || []) {
|
|
1623
1635
|
switch (argumentNode.name.value) {
|
|
1624
|
-
case
|
|
1636
|
+
case string_constants_1.TOPICS: {
|
|
1625
1637
|
//@TODO list coercion
|
|
1626
1638
|
if (argumentNode.value.kind !== graphql_1.Kind.LIST) {
|
|
1627
|
-
errorMessages.push((0, errors_1.invalidEventSubjectsErrorMessage)(
|
|
1639
|
+
errorMessages.push((0, errors_1.invalidEventSubjectsErrorMessage)(string_constants_1.TOPICS));
|
|
1628
1640
|
continue;
|
|
1629
1641
|
}
|
|
1630
1642
|
for (const value of argumentNode.value.values) {
|
|
1631
1643
|
if (value.kind !== graphql_1.Kind.STRING || value.value.length < 1) {
|
|
1632
|
-
errorMessages.push((0, errors_1.invalidEventSubjectsItemErrorMessage)(
|
|
1644
|
+
errorMessages.push((0, errors_1.invalidEventSubjectsItemErrorMessage)(string_constants_1.TOPICS));
|
|
1633
1645
|
break;
|
|
1634
1646
|
}
|
|
1635
1647
|
(0, utils_2.validateArgumentTemplateReferences)(value.value, argumentDataByArgumentName, errorMessages);
|
|
@@ -1637,7 +1649,7 @@ class NormalizationFactory {
|
|
|
1637
1649
|
}
|
|
1638
1650
|
break;
|
|
1639
1651
|
}
|
|
1640
|
-
case
|
|
1652
|
+
case string_constants_1.PROVIDER_ID: {
|
|
1641
1653
|
if (argumentNode.value.kind !== graphql_1.Kind.STRING || argumentNode.value.value.length < 1) {
|
|
1642
1654
|
errorMessages.push(errors_1.invalidEventProviderIdErrorMessage);
|
|
1643
1655
|
continue;
|
|
@@ -1653,26 +1665,26 @@ class NormalizationFactory {
|
|
|
1653
1665
|
return {
|
|
1654
1666
|
fieldName,
|
|
1655
1667
|
providerId,
|
|
1656
|
-
providerType:
|
|
1668
|
+
providerType: string_constants_1.PROVIDER_TYPE_KAFKA,
|
|
1657
1669
|
topics: topics,
|
|
1658
|
-
type:
|
|
1670
|
+
type: string_constants_1.SUBSCRIBE,
|
|
1659
1671
|
};
|
|
1660
1672
|
}
|
|
1661
1673
|
getNatsPublishAndRequestConfiguration(eventType, directive, argumentDataByArgumentName, fieldName, errorMessages) {
|
|
1662
1674
|
const subjects = [];
|
|
1663
|
-
let providerId =
|
|
1675
|
+
let providerId = string_constants_1.DEFAULT_EDFS_PROVIDER_ID;
|
|
1664
1676
|
for (const argumentNode of directive.arguments || []) {
|
|
1665
1677
|
switch (argumentNode.name.value) {
|
|
1666
|
-
case
|
|
1678
|
+
case string_constants_1.SUBJECT: {
|
|
1667
1679
|
if (argumentNode.value.kind !== graphql_1.Kind.STRING || argumentNode.value.value.length < 1) {
|
|
1668
|
-
errorMessages.push((0, errors_1.invalidEventSubjectErrorMessage)(
|
|
1680
|
+
errorMessages.push((0, errors_1.invalidEventSubjectErrorMessage)(string_constants_1.SUBJECT));
|
|
1669
1681
|
continue;
|
|
1670
1682
|
}
|
|
1671
1683
|
(0, utils_2.validateArgumentTemplateReferences)(argumentNode.value.value, argumentDataByArgumentName, errorMessages);
|
|
1672
1684
|
subjects.push(argumentNode.value.value);
|
|
1673
1685
|
break;
|
|
1674
1686
|
}
|
|
1675
|
-
case
|
|
1687
|
+
case string_constants_1.PROVIDER_ID: {
|
|
1676
1688
|
if (argumentNode.value.kind !== graphql_1.Kind.STRING || argumentNode.value.value.length < 1) {
|
|
1677
1689
|
errorMessages.push(errors_1.invalidEventProviderIdErrorMessage);
|
|
1678
1690
|
continue;
|
|
@@ -1685,25 +1697,25 @@ class NormalizationFactory {
|
|
|
1685
1697
|
if (errorMessages.length > 0) {
|
|
1686
1698
|
return;
|
|
1687
1699
|
}
|
|
1688
|
-
return { fieldName, providerId, providerType:
|
|
1700
|
+
return { fieldName, providerId, providerType: string_constants_1.PROVIDER_TYPE_NATS, subjects, type: eventType };
|
|
1689
1701
|
}
|
|
1690
1702
|
getNatsSubscribeConfiguration(directive, argumentDataByArgumentName, fieldName, errorMessages) {
|
|
1691
1703
|
const subjects = [];
|
|
1692
|
-
let providerId =
|
|
1693
|
-
let consumerInactiveThreshold =
|
|
1704
|
+
let providerId = string_constants_1.DEFAULT_EDFS_PROVIDER_ID;
|
|
1705
|
+
let consumerInactiveThreshold = integers_1.DEFAULT_CONSUMER_INACTIVE_THRESHOLD;
|
|
1694
1706
|
let consumerName = '';
|
|
1695
1707
|
let streamName = '';
|
|
1696
1708
|
for (const argumentNode of directive.arguments || []) {
|
|
1697
1709
|
switch (argumentNode.name.value) {
|
|
1698
|
-
case
|
|
1710
|
+
case string_constants_1.SUBJECTS: {
|
|
1699
1711
|
// @TODO list coercion
|
|
1700
1712
|
if (argumentNode.value.kind !== graphql_1.Kind.LIST) {
|
|
1701
|
-
errorMessages.push((0, errors_1.invalidEventSubjectsErrorMessage)(
|
|
1713
|
+
errorMessages.push((0, errors_1.invalidEventSubjectsErrorMessage)(string_constants_1.SUBJECTS));
|
|
1702
1714
|
continue;
|
|
1703
1715
|
}
|
|
1704
1716
|
for (const value of argumentNode.value.values) {
|
|
1705
1717
|
if (value.kind !== graphql_1.Kind.STRING || value.value.length < 1) {
|
|
1706
|
-
errorMessages.push((0, errors_1.invalidEventSubjectsItemErrorMessage)(
|
|
1718
|
+
errorMessages.push((0, errors_1.invalidEventSubjectsItemErrorMessage)(string_constants_1.SUBJECTS));
|
|
1707
1719
|
break;
|
|
1708
1720
|
}
|
|
1709
1721
|
(0, utils_2.validateArgumentTemplateReferences)(value.value, argumentDataByArgumentName, errorMessages);
|
|
@@ -1711,7 +1723,7 @@ class NormalizationFactory {
|
|
|
1711
1723
|
}
|
|
1712
1724
|
break;
|
|
1713
1725
|
}
|
|
1714
|
-
case
|
|
1726
|
+
case string_constants_1.PROVIDER_ID: {
|
|
1715
1727
|
if (argumentNode.value.kind !== graphql_1.Kind.STRING || argumentNode.value.value.length < 1) {
|
|
1716
1728
|
errorMessages.push(errors_1.invalidEventProviderIdErrorMessage);
|
|
1717
1729
|
continue;
|
|
@@ -1719,7 +1731,7 @@ class NormalizationFactory {
|
|
|
1719
1731
|
providerId = argumentNode.value.value;
|
|
1720
1732
|
break;
|
|
1721
1733
|
}
|
|
1722
|
-
case
|
|
1734
|
+
case string_constants_1.STREAM_CONFIGURATION: {
|
|
1723
1735
|
this.usesEdfsNatsStreamConfiguration = true;
|
|
1724
1736
|
if (argumentNode.value.kind !== graphql_1.Kind.OBJECT || argumentNode.value.fields.length < 1) {
|
|
1725
1737
|
errorMessages.push(errors_1.invalidNatsStreamInputErrorMessage);
|
|
@@ -1727,13 +1739,13 @@ class NormalizationFactory {
|
|
|
1727
1739
|
}
|
|
1728
1740
|
let isValid = true;
|
|
1729
1741
|
const invalidFieldNames = new Set();
|
|
1730
|
-
const allowedFieldNames = new Set(
|
|
1731
|
-
const missingRequiredFieldNames = new Set([
|
|
1742
|
+
const allowedFieldNames = new Set(strings_1.STREAM_CONFIGURATION_FIELD_NAMES);
|
|
1743
|
+
const missingRequiredFieldNames = new Set([string_constants_1.CONSUMER_NAME, string_constants_1.STREAM_NAME]);
|
|
1732
1744
|
const duplicateFieldNames = new Set();
|
|
1733
1745
|
const invalidRequiredFieldNames = new Set();
|
|
1734
1746
|
for (const field of argumentNode.value.fields) {
|
|
1735
1747
|
const fieldName = field.name.value;
|
|
1736
|
-
if (!
|
|
1748
|
+
if (!strings_1.STREAM_CONFIGURATION_FIELD_NAMES.has(fieldName)) {
|
|
1737
1749
|
invalidFieldNames.add(fieldName);
|
|
1738
1750
|
isValid = false;
|
|
1739
1751
|
continue;
|
|
@@ -1750,7 +1762,7 @@ class NormalizationFactory {
|
|
|
1750
1762
|
missingRequiredFieldNames.delete(fieldName);
|
|
1751
1763
|
}
|
|
1752
1764
|
switch (fieldName) {
|
|
1753
|
-
case
|
|
1765
|
+
case string_constants_1.CONSUMER_NAME:
|
|
1754
1766
|
if (field.value.kind != graphql_1.Kind.STRING || field.value.value.length < 1) {
|
|
1755
1767
|
invalidRequiredFieldNames.add(fieldName);
|
|
1756
1768
|
isValid = false;
|
|
@@ -1758,7 +1770,7 @@ class NormalizationFactory {
|
|
|
1758
1770
|
}
|
|
1759
1771
|
consumerName = field.value.value;
|
|
1760
1772
|
break;
|
|
1761
|
-
case
|
|
1773
|
+
case string_constants_1.STREAM_NAME:
|
|
1762
1774
|
if (field.value.kind != graphql_1.Kind.STRING || field.value.value.length < 1) {
|
|
1763
1775
|
invalidRequiredFieldNames.add(fieldName);
|
|
1764
1776
|
isValid = false;
|
|
@@ -1766,9 +1778,9 @@ class NormalizationFactory {
|
|
|
1766
1778
|
}
|
|
1767
1779
|
streamName = field.value.value;
|
|
1768
1780
|
break;
|
|
1769
|
-
case
|
|
1781
|
+
case string_constants_1.CONSUMER_INACTIVE_THRESHOLD:
|
|
1770
1782
|
if (field.value.kind != graphql_1.Kind.INT) {
|
|
1771
|
-
errorMessages.push((0, errors_1.invalidArgumentValueErrorMessage)((0, graphql_1.print)(field.value), 'edfs__NatsStreamConfiguration', `consumerInactiveThreshold`,
|
|
1783
|
+
errorMessages.push((0, errors_1.invalidArgumentValueErrorMessage)((0, graphql_1.print)(field.value), 'edfs__NatsStreamConfiguration', `consumerInactiveThreshold`, string_constants_1.INT_SCALAR));
|
|
1772
1784
|
isValid = false;
|
|
1773
1785
|
continue;
|
|
1774
1786
|
}
|
|
@@ -1777,7 +1789,7 @@ class NormalizationFactory {
|
|
|
1777
1789
|
consumerInactiveThreshold = parseInt(field.value.value, 10);
|
|
1778
1790
|
}
|
|
1779
1791
|
catch (e) {
|
|
1780
|
-
errorMessages.push((0, errors_1.invalidArgumentValueErrorMessage)((0, graphql_1.print)(field.value), 'edfs__NatsStreamConfiguration', `consumerInactiveThreshold`,
|
|
1792
|
+
errorMessages.push((0, errors_1.invalidArgumentValueErrorMessage)((0, graphql_1.print)(field.value), 'edfs__NatsStreamConfiguration', `consumerInactiveThreshold`, string_constants_1.INT_SCALAR));
|
|
1781
1793
|
isValid = false;
|
|
1782
1794
|
}
|
|
1783
1795
|
break;
|
|
@@ -1793,19 +1805,19 @@ class NormalizationFactory {
|
|
|
1793
1805
|
return;
|
|
1794
1806
|
}
|
|
1795
1807
|
if (consumerInactiveThreshold < 0) {
|
|
1796
|
-
consumerInactiveThreshold =
|
|
1797
|
-
this.warnings.push((0, warnings_1.consumerInactiveThresholdInvalidValueWarning)(this.subgraphName, `The value has been set to ${
|
|
1808
|
+
consumerInactiveThreshold = integers_1.DEFAULT_CONSUMER_INACTIVE_THRESHOLD;
|
|
1809
|
+
this.warnings.push((0, warnings_1.consumerInactiveThresholdInvalidValueWarning)(this.subgraphName, `The value has been set to ${integers_1.DEFAULT_CONSUMER_INACTIVE_THRESHOLD}.`));
|
|
1798
1810
|
}
|
|
1799
|
-
else if (consumerInactiveThreshold >
|
|
1811
|
+
else if (consumerInactiveThreshold > integer_constants_1.MAX_INT32) {
|
|
1800
1812
|
consumerInactiveThreshold = 0;
|
|
1801
1813
|
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.'));
|
|
1802
1814
|
}
|
|
1803
1815
|
return {
|
|
1804
1816
|
fieldName,
|
|
1805
1817
|
providerId,
|
|
1806
|
-
providerType:
|
|
1818
|
+
providerType: string_constants_1.PROVIDER_TYPE_NATS,
|
|
1807
1819
|
subjects,
|
|
1808
|
-
type:
|
|
1820
|
+
type: string_constants_1.SUBSCRIBE,
|
|
1809
1821
|
...(consumerName && streamName
|
|
1810
1822
|
? {
|
|
1811
1823
|
streamConfiguration: {
|
|
@@ -1819,19 +1831,19 @@ class NormalizationFactory {
|
|
|
1819
1831
|
}
|
|
1820
1832
|
getRedisPublishConfiguration(directive, argumentDataByArgumentName, fieldName, errorMessages) {
|
|
1821
1833
|
const channels = [];
|
|
1822
|
-
let providerId =
|
|
1834
|
+
let providerId = string_constants_1.DEFAULT_EDFS_PROVIDER_ID;
|
|
1823
1835
|
for (const argumentNode of directive.arguments || []) {
|
|
1824
1836
|
switch (argumentNode.name.value) {
|
|
1825
|
-
case
|
|
1837
|
+
case string_constants_1.CHANNEL: {
|
|
1826
1838
|
if (argumentNode.value.kind !== graphql_1.Kind.STRING || argumentNode.value.value.length < 1) {
|
|
1827
|
-
errorMessages.push((0, errors_1.invalidEventSubjectErrorMessage)(
|
|
1839
|
+
errorMessages.push((0, errors_1.invalidEventSubjectErrorMessage)(string_constants_1.CHANNEL));
|
|
1828
1840
|
continue;
|
|
1829
1841
|
}
|
|
1830
1842
|
(0, utils_2.validateArgumentTemplateReferences)(argumentNode.value.value, argumentDataByArgumentName, errorMessages);
|
|
1831
1843
|
channels.push(argumentNode.value.value);
|
|
1832
1844
|
break;
|
|
1833
1845
|
}
|
|
1834
|
-
case
|
|
1846
|
+
case string_constants_1.PROVIDER_ID: {
|
|
1835
1847
|
if (argumentNode.value.kind !== graphql_1.Kind.STRING || argumentNode.value.value.length < 1) {
|
|
1836
1848
|
errorMessages.push(errors_1.invalidEventProviderIdErrorMessage);
|
|
1837
1849
|
continue;
|
|
@@ -1844,22 +1856,22 @@ class NormalizationFactory {
|
|
|
1844
1856
|
if (errorMessages.length > 0) {
|
|
1845
1857
|
return;
|
|
1846
1858
|
}
|
|
1847
|
-
return { fieldName, providerId, providerType:
|
|
1859
|
+
return { fieldName, providerId, providerType: string_constants_1.PROVIDER_TYPE_REDIS, channels, type: string_constants_1.PUBLISH };
|
|
1848
1860
|
}
|
|
1849
1861
|
getRedisSubscribeConfiguration(directive, argumentDataByArgumentName, fieldName, errorMessages) {
|
|
1850
1862
|
const channels = [];
|
|
1851
|
-
let providerId =
|
|
1863
|
+
let providerId = string_constants_1.DEFAULT_EDFS_PROVIDER_ID;
|
|
1852
1864
|
for (const argumentNode of directive.arguments || []) {
|
|
1853
1865
|
switch (argumentNode.name.value) {
|
|
1854
|
-
case
|
|
1866
|
+
case string_constants_1.CHANNELS: {
|
|
1855
1867
|
//@TODO list coercion
|
|
1856
1868
|
if (argumentNode.value.kind !== graphql_1.Kind.LIST) {
|
|
1857
|
-
errorMessages.push((0, errors_1.invalidEventSubjectsErrorMessage)(
|
|
1869
|
+
errorMessages.push((0, errors_1.invalidEventSubjectsErrorMessage)(string_constants_1.CHANNELS));
|
|
1858
1870
|
continue;
|
|
1859
1871
|
}
|
|
1860
1872
|
for (const value of argumentNode.value.values) {
|
|
1861
1873
|
if (value.kind !== graphql_1.Kind.STRING || value.value.length < 1) {
|
|
1862
|
-
errorMessages.push((0, errors_1.invalidEventSubjectsItemErrorMessage)(
|
|
1874
|
+
errorMessages.push((0, errors_1.invalidEventSubjectsItemErrorMessage)(string_constants_1.CHANNELS));
|
|
1863
1875
|
break;
|
|
1864
1876
|
}
|
|
1865
1877
|
(0, utils_2.validateArgumentTemplateReferences)(value.value, argumentDataByArgumentName, errorMessages);
|
|
@@ -1867,7 +1879,7 @@ class NormalizationFactory {
|
|
|
1867
1879
|
}
|
|
1868
1880
|
break;
|
|
1869
1881
|
}
|
|
1870
|
-
case
|
|
1882
|
+
case string_constants_1.PROVIDER_ID: {
|
|
1871
1883
|
if (argumentNode.value.kind !== graphql_1.Kind.STRING || argumentNode.value.value.length < 1) {
|
|
1872
1884
|
errorMessages.push(errors_1.invalidEventProviderIdErrorMessage);
|
|
1873
1885
|
continue;
|
|
@@ -1883,9 +1895,9 @@ class NormalizationFactory {
|
|
|
1883
1895
|
return {
|
|
1884
1896
|
fieldName,
|
|
1885
1897
|
providerId,
|
|
1886
|
-
providerType:
|
|
1898
|
+
providerType: string_constants_1.PROVIDER_TYPE_REDIS,
|
|
1887
1899
|
channels,
|
|
1888
|
-
type:
|
|
1900
|
+
type: string_constants_1.SUBSCRIBE,
|
|
1889
1901
|
};
|
|
1890
1902
|
}
|
|
1891
1903
|
validateSubscriptionFilterDirectiveLocation(node) {
|
|
@@ -1896,7 +1908,7 @@ class NormalizationFactory {
|
|
|
1896
1908
|
const fieldCoords = `${parentTypeName}.${node.name.value}`;
|
|
1897
1909
|
const isSubscription = this.getOperationTypeNodeForRootTypeName(parentTypeName) === graphql_1.OperationTypeNode.SUBSCRIPTION;
|
|
1898
1910
|
for (const directiveNode of node.directives) {
|
|
1899
|
-
if (directiveNode.name.value !==
|
|
1911
|
+
if (directiveNode.name.value !== string_constants_1.SUBSCRIPTION_FILTER) {
|
|
1900
1912
|
continue;
|
|
1901
1913
|
}
|
|
1902
1914
|
if (!isSubscription) {
|
|
@@ -1916,29 +1928,29 @@ class NormalizationFactory {
|
|
|
1916
1928
|
const errorMessages = [];
|
|
1917
1929
|
let eventConfiguration;
|
|
1918
1930
|
switch (directive.name.value) {
|
|
1919
|
-
case
|
|
1931
|
+
case string_constants_1.EDFS_KAFKA_PUBLISH:
|
|
1920
1932
|
eventConfiguration = this.getKafkaPublishConfiguration(directive, argumentDataByArgumentName, fieldName, errorMessages);
|
|
1921
1933
|
break;
|
|
1922
|
-
case
|
|
1934
|
+
case string_constants_1.EDFS_KAFKA_SUBSCRIBE:
|
|
1923
1935
|
eventConfiguration = this.getKafkaSubscribeConfiguration(directive, argumentDataByArgumentName, fieldName, errorMessages);
|
|
1924
1936
|
break;
|
|
1925
|
-
case
|
|
1926
|
-
eventConfiguration = this.getNatsPublishAndRequestConfiguration(
|
|
1937
|
+
case string_constants_1.EDFS_NATS_PUBLISH: {
|
|
1938
|
+
eventConfiguration = this.getNatsPublishAndRequestConfiguration(string_constants_1.PUBLISH, directive, argumentDataByArgumentName, fieldName, errorMessages);
|
|
1927
1939
|
break;
|
|
1928
1940
|
}
|
|
1929
|
-
case
|
|
1930
|
-
eventConfiguration = this.getNatsPublishAndRequestConfiguration(
|
|
1941
|
+
case string_constants_1.EDFS_NATS_REQUEST: {
|
|
1942
|
+
eventConfiguration = this.getNatsPublishAndRequestConfiguration(string_constants_1.REQUEST, directive, argumentDataByArgumentName, fieldName, errorMessages);
|
|
1931
1943
|
break;
|
|
1932
1944
|
}
|
|
1933
|
-
case
|
|
1945
|
+
case string_constants_1.EDFS_NATS_SUBSCRIBE: {
|
|
1934
1946
|
eventConfiguration = this.getNatsSubscribeConfiguration(directive, argumentDataByArgumentName, fieldName, errorMessages);
|
|
1935
1947
|
break;
|
|
1936
1948
|
}
|
|
1937
|
-
case
|
|
1949
|
+
case string_constants_1.EDFS_REDIS_PUBLISH: {
|
|
1938
1950
|
eventConfiguration = this.getRedisPublishConfiguration(directive, argumentDataByArgumentName, fieldName, errorMessages);
|
|
1939
1951
|
break;
|
|
1940
1952
|
}
|
|
1941
|
-
case
|
|
1953
|
+
case string_constants_1.EDFS_REDIS_SUBSCRIBE: {
|
|
1942
1954
|
eventConfiguration = this.getRedisSubscribeConfiguration(directive, argumentDataByArgumentName, fieldName, errorMessages);
|
|
1943
1955
|
break;
|
|
1944
1956
|
}
|
|
@@ -1959,11 +1971,11 @@ class NormalizationFactory {
|
|
|
1959
1971
|
getValidEventsDirectiveNamesForOperationTypeNode(operationTypeNode) {
|
|
1960
1972
|
switch (operationTypeNode) {
|
|
1961
1973
|
case graphql_1.OperationTypeNode.MUTATION:
|
|
1962
|
-
return new Set([
|
|
1974
|
+
return new Set([string_constants_1.EDFS_KAFKA_PUBLISH, string_constants_1.EDFS_NATS_PUBLISH, string_constants_1.EDFS_NATS_REQUEST, string_constants_1.EDFS_REDIS_PUBLISH]);
|
|
1963
1975
|
case graphql_1.OperationTypeNode.QUERY:
|
|
1964
|
-
return new Set([
|
|
1976
|
+
return new Set([string_constants_1.EDFS_NATS_REQUEST]);
|
|
1965
1977
|
case graphql_1.OperationTypeNode.SUBSCRIPTION:
|
|
1966
|
-
return new Set([
|
|
1978
|
+
return new Set([string_constants_1.EDFS_KAFKA_SUBSCRIBE, string_constants_1.EDFS_NATS_SUBSCRIBE, string_constants_1.EDFS_REDIS_SUBSCRIBE]);
|
|
1967
1979
|
}
|
|
1968
1980
|
}
|
|
1969
1981
|
getOperationTypeNodeForRootTypeName(parentTypeName) {
|
|
@@ -1972,11 +1984,11 @@ class NormalizationFactory {
|
|
|
1972
1984
|
return operationTypeNode;
|
|
1973
1985
|
}
|
|
1974
1986
|
switch (parentTypeName) {
|
|
1975
|
-
case
|
|
1987
|
+
case string_constants_1.MUTATION:
|
|
1976
1988
|
return graphql_1.OperationTypeNode.MUTATION;
|
|
1977
|
-
case
|
|
1989
|
+
case string_constants_1.QUERY:
|
|
1978
1990
|
return graphql_1.OperationTypeNode.QUERY;
|
|
1979
|
-
case
|
|
1991
|
+
case string_constants_1.SUBSCRIPTION:
|
|
1980
1992
|
return graphql_1.OperationTypeNode.SUBSCRIPTION;
|
|
1981
1993
|
default:
|
|
1982
1994
|
return;
|
|
@@ -1993,7 +2005,7 @@ class NormalizationFactory {
|
|
|
1993
2005
|
for (const [fieldName, fieldData] of data.fieldDataByName) {
|
|
1994
2006
|
const fieldCoords = `${fieldData.originalParentTypeName}.${fieldName}`;
|
|
1995
2007
|
const definedEventsDirectiveNames = new Set();
|
|
1996
|
-
for (const eventsDirectiveName of
|
|
2008
|
+
for (const eventsDirectiveName of strings_1.EVENT_DIRECTIVE_NAMES) {
|
|
1997
2009
|
if (fieldData.directivesByDirectiveName.has(eventsDirectiveName)) {
|
|
1998
2010
|
definedEventsDirectiveNames.add(eventsDirectiveName);
|
|
1999
2011
|
}
|
|
@@ -2012,7 +2024,7 @@ class NormalizationFactory {
|
|
|
2012
2024
|
}
|
|
2013
2025
|
if (operationTypeNode === graphql_1.OperationTypeNode.MUTATION) {
|
|
2014
2026
|
const typeString = (0, merge_1.printTypeNode)(fieldData.type);
|
|
2015
|
-
if (typeString !==
|
|
2027
|
+
if (typeString !== string_constants_1.NON_NULLABLE_EDFS_PUBLISH_EVENT_RESULT) {
|
|
2016
2028
|
invalidResponseTypeNameByMutationPath.set(fieldCoords, typeString);
|
|
2017
2029
|
}
|
|
2018
2030
|
continue;
|
|
@@ -2058,7 +2070,7 @@ class NormalizationFactory {
|
|
|
2058
2070
|
}
|
|
2059
2071
|
}
|
|
2060
2072
|
isEdfsPublishResultValid() {
|
|
2061
|
-
const data = this.parentDefinitionDataByTypeName.get(
|
|
2073
|
+
const data = this.parentDefinitionDataByTypeName.get(string_constants_1.EDFS_PUBLISH_RESULT);
|
|
2062
2074
|
if (!data) {
|
|
2063
2075
|
return true;
|
|
2064
2076
|
}
|
|
@@ -2072,17 +2084,17 @@ class NormalizationFactory {
|
|
|
2072
2084
|
if (fieldData.argumentDataByName.size > 0) {
|
|
2073
2085
|
return false;
|
|
2074
2086
|
}
|
|
2075
|
-
if (fieldName !==
|
|
2087
|
+
if (fieldName !== string_constants_1.SUCCESS) {
|
|
2076
2088
|
return false;
|
|
2077
2089
|
}
|
|
2078
|
-
if ((0, merge_1.printTypeNode)(fieldData.type) !==
|
|
2090
|
+
if ((0, merge_1.printTypeNode)(fieldData.type) !== string_constants_1.NON_NULLABLE_BOOLEAN) {
|
|
2079
2091
|
return false;
|
|
2080
2092
|
}
|
|
2081
2093
|
}
|
|
2082
2094
|
return true;
|
|
2083
2095
|
}
|
|
2084
2096
|
isNatsStreamConfigurationInputObjectValid(streamConfigurationInputData) {
|
|
2085
|
-
if (
|
|
2097
|
+
if (!(0, utils_4.isInputObjectDefinitionData)(streamConfigurationInputData)) {
|
|
2086
2098
|
return false;
|
|
2087
2099
|
}
|
|
2088
2100
|
if (streamConfigurationInputData.inputValueDataByName.size != 3) {
|
|
@@ -2090,21 +2102,21 @@ class NormalizationFactory {
|
|
|
2090
2102
|
}
|
|
2091
2103
|
for (const [inputValueName, inputValueData] of streamConfigurationInputData.inputValueDataByName) {
|
|
2092
2104
|
switch (inputValueName) {
|
|
2093
|
-
case
|
|
2094
|
-
if ((0, merge_1.printTypeNode)(inputValueData.type) !==
|
|
2105
|
+
case string_constants_1.CONSUMER_INACTIVE_THRESHOLD: {
|
|
2106
|
+
if ((0, merge_1.printTypeNode)(inputValueData.type) !== string_constants_1.NON_NULLABLE_INT) {
|
|
2095
2107
|
return false;
|
|
2096
2108
|
}
|
|
2097
2109
|
if (!inputValueData.defaultValue ||
|
|
2098
2110
|
inputValueData.defaultValue.kind !== graphql_1.Kind.INT ||
|
|
2099
|
-
inputValueData.defaultValue.value !== `${
|
|
2111
|
+
inputValueData.defaultValue.value !== `${integers_1.DEFAULT_CONSUMER_INACTIVE_THRESHOLD}`) {
|
|
2100
2112
|
return false;
|
|
2101
2113
|
}
|
|
2102
2114
|
break;
|
|
2103
2115
|
}
|
|
2104
|
-
case
|
|
2116
|
+
case string_constants_1.CONSUMER_NAME:
|
|
2105
2117
|
// intentional fallthrough
|
|
2106
|
-
case
|
|
2107
|
-
if ((0, merge_1.printTypeNode)(inputValueData.type) !==
|
|
2118
|
+
case string_constants_1.STREAM_NAME: {
|
|
2119
|
+
if ((0, merge_1.printTypeNode)(inputValueData.type) !== string_constants_1.NON_NULLABLE_STRING) {
|
|
2108
2120
|
return false;
|
|
2109
2121
|
}
|
|
2110
2122
|
break;
|
|
@@ -2116,7 +2128,7 @@ class NormalizationFactory {
|
|
|
2116
2128
|
}
|
|
2117
2129
|
return true;
|
|
2118
2130
|
}
|
|
2119
|
-
validateEventDrivenSubgraph(
|
|
2131
|
+
validateEventDrivenSubgraph() {
|
|
2120
2132
|
const errorMessages = [];
|
|
2121
2133
|
const invalidEventsDirectiveDataByRootFieldPath = new Map();
|
|
2122
2134
|
const invalidResponseTypeStringByRootFieldPath = new Map();
|
|
@@ -2128,7 +2140,7 @@ class NormalizationFactory {
|
|
|
2128
2140
|
const invalidObjectTypeNames = new Set();
|
|
2129
2141
|
for (const [typeName, data] of this.parentDefinitionDataByTypeName) {
|
|
2130
2142
|
// validate edfs__PublishResult and edfs__NatsStreamConfiguration separately
|
|
2131
|
-
if (typeName ===
|
|
2143
|
+
if (typeName === string_constants_1.EDFS_PUBLISH_RESULT || typeName === string_constants_1.EDFS_NATS_STREAM_CONFIGURATION) {
|
|
2132
2144
|
continue;
|
|
2133
2145
|
}
|
|
2134
2146
|
if (data.kind !== graphql_1.Kind.OBJECT_TYPE_DEFINITION) {
|
|
@@ -2149,16 +2161,34 @@ class NormalizationFactory {
|
|
|
2149
2161
|
if (!this.isEdfsPublishResultValid()) {
|
|
2150
2162
|
errorMessages.push(errors_1.invalidEdfsPublishResultObjectErrorMessage);
|
|
2151
2163
|
}
|
|
2152
|
-
if (this.edfsDirectiveReferences.has(
|
|
2153
|
-
const streamConfigurationInputData = this.parentDefinitionDataByTypeName.get(
|
|
2164
|
+
if (this.edfsDirectiveReferences.has(string_constants_1.EDFS_NATS_SUBSCRIBE)) {
|
|
2165
|
+
const streamConfigurationInputData = this.parentDefinitionDataByTypeName.get(string_constants_1.EDFS_NATS_STREAM_CONFIGURATION);
|
|
2154
2166
|
if (streamConfigurationInputData &&
|
|
2155
2167
|
this.usesEdfsNatsStreamConfiguration &&
|
|
2156
2168
|
!this.isNatsStreamConfigurationInputObjectValid(streamConfigurationInputData)) {
|
|
2157
2169
|
errorMessages.push(errors_1.invalidNatsStreamConfigurationDefinitionErrorMessage);
|
|
2158
2170
|
}
|
|
2159
|
-
//
|
|
2160
|
-
this.parentDefinitionDataByTypeName.delete(
|
|
2161
|
-
|
|
2171
|
+
// Inject the correct dependency
|
|
2172
|
+
this.parentDefinitionDataByTypeName.delete(string_constants_1.EDFS_NATS_STREAM_CONFIGURATION);
|
|
2173
|
+
const result = this.upsertInputObjectByNode(non_directive_definitions_1.EDFS_NATS_STREAM_CONFIGURATION_DEFINITION);
|
|
2174
|
+
// The result cannot actually be unsuccessful
|
|
2175
|
+
if (result.success) {
|
|
2176
|
+
for (const fieldNode of non_directive_definitions_1.EDFS_NATS_STREAM_CONFIGURATION_DEFINITION.fields) {
|
|
2177
|
+
this.addInputValueDataByNode({
|
|
2178
|
+
fieldName: fieldNode.name.value,
|
|
2179
|
+
isArgument: false,
|
|
2180
|
+
inputValueDataByName: result.data.inputValueDataByName,
|
|
2181
|
+
node: fieldNode,
|
|
2182
|
+
originalParentTypeName: string_constants_1.EDFS_NATS_STREAM_CONFIGURATION,
|
|
2183
|
+
});
|
|
2184
|
+
}
|
|
2185
|
+
}
|
|
2186
|
+
else {
|
|
2187
|
+
/* Should never happen, but if somehow it did, an error has already been appended from the
|
|
2188
|
+
* `upsertInputObjectByNode` method.
|
|
2189
|
+
*/
|
|
2190
|
+
return;
|
|
2191
|
+
}
|
|
2162
2192
|
}
|
|
2163
2193
|
if (invalidEventsDirectiveDataByRootFieldPath.size > 0) {
|
|
2164
2194
|
errorMessages.push((0, errors_1.invalidRootTypeFieldEventsDirectivesErrorMessage)(invalidEventsDirectiveDataByRootFieldPath));
|
|
@@ -2238,10 +2268,10 @@ class NormalizationFactory {
|
|
|
2238
2268
|
getValidFlattenedDirectiveArray(directivesByDirectiveName, directiveCoords, removeInheritedDirectives = false) {
|
|
2239
2269
|
const flattenedArray = [];
|
|
2240
2270
|
for (const [directiveName, directiveNodes] of directivesByDirectiveName) {
|
|
2241
|
-
if (removeInheritedDirectives &&
|
|
2271
|
+
if (removeInheritedDirectives && string_constants_1.INHERITABLE_DIRECTIVE_NAMES.has(directiveName)) {
|
|
2242
2272
|
continue;
|
|
2243
2273
|
}
|
|
2244
|
-
const directiveDefinition = this.
|
|
2274
|
+
const directiveDefinition = this.directiveDefinitionDataByName.get(directiveName);
|
|
2245
2275
|
if (!directiveDefinition) {
|
|
2246
2276
|
continue;
|
|
2247
2277
|
}
|
|
@@ -2255,7 +2285,7 @@ class NormalizationFactory {
|
|
|
2255
2285
|
}
|
|
2256
2286
|
continue;
|
|
2257
2287
|
}
|
|
2258
|
-
if (directiveName !==
|
|
2288
|
+
if (directiveName !== string_constants_1.KEY) {
|
|
2259
2289
|
flattenedArray.push(...directiveNodes);
|
|
2260
2290
|
continue;
|
|
2261
2291
|
}
|
|
@@ -2491,7 +2521,7 @@ class NormalizationFactory {
|
|
|
2491
2521
|
}
|
|
2492
2522
|
}
|
|
2493
2523
|
validateOneOfDirective({ data, requiredFieldNames }) {
|
|
2494
|
-
if (!data.directivesByDirectiveName.has(
|
|
2524
|
+
if (!data.directivesByDirectiveName.has(string_constants_1.ONE_OF)) {
|
|
2495
2525
|
return true;
|
|
2496
2526
|
}
|
|
2497
2527
|
if (requiredFieldNames.size > 0) {
|
|
@@ -2510,72 +2540,39 @@ class NormalizationFactory {
|
|
|
2510
2540
|
}
|
|
2511
2541
|
return true;
|
|
2512
2542
|
}
|
|
2543
|
+
#addDirectiveDefinitionsToDocument(definitions) {
|
|
2544
|
+
const dependencies = new Set();
|
|
2545
|
+
for (const directiveName of this.referencedDirectiveNames) {
|
|
2546
|
+
const definition = constants_1.DIRECTIVE_DEFINITION_BY_NAME.get(directiveName);
|
|
2547
|
+
if (!definition) {
|
|
2548
|
+
continue;
|
|
2549
|
+
}
|
|
2550
|
+
this.directiveDefinitionByName.set(directiveName, definition);
|
|
2551
|
+
(0, utils_5.addOptionalIterableToSet)({
|
|
2552
|
+
source: strings_1.DEPENDENCIES_BY_DIRECTIVE_NAME.get(directiveName),
|
|
2553
|
+
target: dependencies,
|
|
2554
|
+
});
|
|
2555
|
+
definitions.push(definition);
|
|
2556
|
+
}
|
|
2557
|
+
// Always include custom directive definitions regardless of use.
|
|
2558
|
+
for (const definition of this.customDirectiveDefinitionByName.values()) {
|
|
2559
|
+
definitions.push(definition);
|
|
2560
|
+
}
|
|
2561
|
+
definitions.push(...dependencies);
|
|
2562
|
+
}
|
|
2513
2563
|
normalize(document) {
|
|
2514
|
-
/* factory.allDirectiveDefinitions is initialized with v1 directive definitions, and v2 definitions are only added
|
|
2515
|
-
after the visitor has visited the entire schema and the subgraph is known to be a V2 graph. Consequently,
|
|
2516
|
-
allDirectiveDefinitions cannot be used to check for duplicate definitions, and another set (below) is required */
|
|
2517
2564
|
// Collect any renamed root types
|
|
2518
2565
|
(0, walkers_1.upsertDirectiveSchemaAndEntityDefinitions)(this, document);
|
|
2519
2566
|
(0, walkers_1.upsertParentsAndChildren)(this, document);
|
|
2520
|
-
|
|
2567
|
+
const definitions = [];
|
|
2568
|
+
this.#addDirectiveDefinitionsToDocument(definitions);
|
|
2569
|
+
this.validateDirectives(this.schemaData, string_constants_1.SCHEMA);
|
|
2521
2570
|
for (const [parentTypeName, parentData] of this.parentDefinitionDataByTypeName) {
|
|
2522
2571
|
this.validateDirectives(parentData, parentTypeName);
|
|
2523
2572
|
}
|
|
2524
2573
|
if (this.invalidORScopesCoords.size > 0) {
|
|
2525
2574
|
this.errors.push((0, errors_1.orScopesLimitError)(constants_1.MAX_OR_SCOPES, [...this.invalidORScopesCoords]));
|
|
2526
2575
|
}
|
|
2527
|
-
const definitions = [];
|
|
2528
|
-
for (const directiveDefinition of constants_1.BASE_DIRECTIVE_DEFINITIONS) {
|
|
2529
|
-
definitions.push(directiveDefinition);
|
|
2530
|
-
}
|
|
2531
|
-
definitions.push(constants_1.FIELD_SET_SCALAR_DEFINITION);
|
|
2532
|
-
if (this.isSubgraphVersionTwo) {
|
|
2533
|
-
for (const directiveDefinition of constants_1.VERSION_TWO_DIRECTIVE_DEFINITIONS) {
|
|
2534
|
-
definitions.push(directiveDefinition);
|
|
2535
|
-
this.directiveDefinitionByDirectiveName.set(directiveDefinition.name.value, directiveDefinition);
|
|
2536
|
-
}
|
|
2537
|
-
definitions.push(constants_1.SCOPE_SCALAR_DEFINITION);
|
|
2538
|
-
}
|
|
2539
|
-
for (const directiveName of this.edfsDirectiveReferences) {
|
|
2540
|
-
const directiveDefinition = constants_1.EVENT_DRIVEN_DIRECTIVE_DEFINITIONS_BY_DIRECTIVE_NAME.get(directiveName);
|
|
2541
|
-
if (!directiveDefinition) {
|
|
2542
|
-
// should never happen
|
|
2543
|
-
this.errors.push((0, errors_1.invalidEdfsDirectiveName)(directiveName));
|
|
2544
|
-
continue;
|
|
2545
|
-
}
|
|
2546
|
-
definitions.push(directiveDefinition);
|
|
2547
|
-
}
|
|
2548
|
-
// subscriptionFilter is temporarily valid only in an EDG
|
|
2549
|
-
if (this.edfsDirectiveReferences.size > 0 && this.referencedDirectiveNames.has(string_constants_2.SUBSCRIPTION_FILTER)) {
|
|
2550
|
-
definitions.push(constants_1.SUBSCRIPTION_FILTER_DEFINITION);
|
|
2551
|
-
definitions.push(constants_1.SUBSCRIPTION_FILTER_CONDITION_DEFINITION);
|
|
2552
|
-
definitions.push(constants_1.SUBSCRIPTION_FIELD_CONDITION_DEFINITION);
|
|
2553
|
-
definitions.push(constants_1.SUBSCRIPTION_FILTER_VALUE_DEFINITION);
|
|
2554
|
-
}
|
|
2555
|
-
if (this.referencedDirectiveNames.has(string_constants_2.CONFIGURE_DESCRIPTION)) {
|
|
2556
|
-
definitions.push(constants_1.CONFIGURE_DESCRIPTION_DEFINITION);
|
|
2557
|
-
}
|
|
2558
|
-
if (this.referencedDirectiveNames.has(string_constants_2.CONFIGURE_CHILD_DESCRIPTIONS)) {
|
|
2559
|
-
definitions.push(constants_1.CONFIGURE_CHILD_DESCRIPTIONS_DEFINITION);
|
|
2560
|
-
}
|
|
2561
|
-
if (this.referencedDirectiveNames.has(string_constants_2.LINK)) {
|
|
2562
|
-
definitions.push(constants_1.LINK_DEFINITION);
|
|
2563
|
-
definitions.push(constants_1.LINK_IMPORT_DEFINITION);
|
|
2564
|
-
definitions.push(constants_1.LINK_PURPOSE_DEFINITION);
|
|
2565
|
-
}
|
|
2566
|
-
// @oneOf is part of the new base schema, so this definition is/will be unnecessary, but add it as a precaution.
|
|
2567
|
-
if (this.referencedDirectiveNames.has(string_constants_2.ONE_OF)) {
|
|
2568
|
-
definitions.push(constants_1.ONE_OF_DEFINITION);
|
|
2569
|
-
}
|
|
2570
|
-
if (this.referencedDirectiveNames.has(string_constants_2.REQUIRE_FETCH_REASONS)) {
|
|
2571
|
-
definitions.push(constants_1.REQUIRE_FETCH_REASONS_DEFINITION);
|
|
2572
|
-
}
|
|
2573
|
-
if (this.referencedDirectiveNames.has(string_constants_2.SEMANTIC_NON_NULL)) {
|
|
2574
|
-
definitions.push(constants_1.SEMANTIC_NON_NULL_DEFINITION);
|
|
2575
|
-
}
|
|
2576
|
-
for (const directiveDefinition of this.customDirectiveDefinitions.values()) {
|
|
2577
|
-
definitions.push(directiveDefinition);
|
|
2578
|
-
}
|
|
2579
2576
|
if (this.schemaData.operationTypes.size > 0) {
|
|
2580
2577
|
definitions.push(this.getSchemaNodeByData(this.schemaData));
|
|
2581
2578
|
}
|
|
@@ -2632,7 +2629,10 @@ class NormalizationFactory {
|
|
|
2632
2629
|
if (!this.validateOneOfDirective({ data: parentData, requiredFieldNames })) {
|
|
2633
2630
|
break;
|
|
2634
2631
|
}
|
|
2635
|
-
|
|
2632
|
+
// The definition is conditionally pushed elsewhere.
|
|
2633
|
+
if (parentTypeName !== string_constants_1.EDFS_NATS_STREAM_CONFIGURATION) {
|
|
2634
|
+
definitions.push(this.getInputObjectNodeByData(parentData));
|
|
2635
|
+
}
|
|
2636
2636
|
break;
|
|
2637
2637
|
}
|
|
2638
2638
|
case graphql_1.Kind.INTERFACE_TYPE_DEFINITION:
|
|
@@ -2646,8 +2646,8 @@ class NormalizationFactory {
|
|
|
2646
2646
|
parentData.extensionType = types_1.ExtensionType.NONE;
|
|
2647
2647
|
}
|
|
2648
2648
|
if (operationTypeNode) {
|
|
2649
|
-
parentData.fieldDataByName.delete(
|
|
2650
|
-
parentData.fieldDataByName.delete(
|
|
2649
|
+
parentData.fieldDataByName.delete(string_constants_1.SERVICE_FIELD);
|
|
2650
|
+
parentData.fieldDataByName.delete(string_constants_1.ENTITIES_FIELD);
|
|
2651
2651
|
}
|
|
2652
2652
|
const externalInterfaceFieldNames = [];
|
|
2653
2653
|
for (const [fieldName, fieldData] of parentData.fieldDataByName) {
|
|
@@ -2690,7 +2690,10 @@ class NormalizationFactory {
|
|
|
2690
2690
|
entityInterfaceData.fieldDatas = (0, utils_3.fieldDatasToSimpleFieldDatas)(parentData.fieldDataByName.values());
|
|
2691
2691
|
const concreteTypeNames = this.concreteTypeNamesByAbstractTypeName.get(parentTypeName);
|
|
2692
2692
|
if (concreteTypeNames) {
|
|
2693
|
-
(0, utils_5.
|
|
2693
|
+
(0, utils_5.addIterableToSet)({
|
|
2694
|
+
source: concreteTypeNames,
|
|
2695
|
+
target: entityInterfaceData.concreteTypeNames,
|
|
2696
|
+
});
|
|
2694
2697
|
}
|
|
2695
2698
|
configurationData.isInterfaceObject = entityInterfaceData.isInterfaceObject;
|
|
2696
2699
|
configurationData.entityInterfaceConcreteTypeNames = entityInterfaceData.concreteTypeNames;
|
|
@@ -2736,7 +2739,7 @@ class NormalizationFactory {
|
|
|
2736
2739
|
// Check that explicitly defined operations types are valid objects and that their fields are also valid
|
|
2737
2740
|
for (const operationType of Object.values(graphql_1.OperationTypeNode)) {
|
|
2738
2741
|
const operationTypeNode = this.schemaData.operationTypes.get(operationType);
|
|
2739
|
-
const defaultTypeName = (0, utils_5.getOrThrowError)(utils_1.operationTypeNodeToDefaultType, operationType,
|
|
2742
|
+
const defaultTypeName = (0, utils_5.getOrThrowError)(utils_1.operationTypeNodeToDefaultType, operationType, string_constants_1.OPERATION_TO_DEFAULT);
|
|
2740
2743
|
// If an operation type name was not declared, use the default
|
|
2741
2744
|
const operationTypeName = operationTypeNode ? (0, ast_1.getTypeNodeNamedTypeName)(operationTypeNode.type) : defaultTypeName;
|
|
2742
2745
|
// This check is so undefined type errors are not improperly propagated
|
|
@@ -2787,7 +2790,7 @@ class NormalizationFactory {
|
|
|
2787
2790
|
}
|
|
2788
2791
|
}
|
|
2789
2792
|
const persistedDirectiveDefinitionDataByDirectiveName = new Map();
|
|
2790
|
-
for (const directiveDefinitionNode of this.
|
|
2793
|
+
for (const directiveDefinitionNode of this.directiveDefinitionByName.values()) {
|
|
2791
2794
|
// TODO @composeDirective directives would also be handled here
|
|
2792
2795
|
const executableLocations = (0, utils_1.extractExecutableDirectiveLocations)(directiveDefinitionNode.locations, new Set());
|
|
2793
2796
|
if (executableLocations.size < 1) {
|
|
@@ -2797,7 +2800,7 @@ class NormalizationFactory {
|
|
|
2797
2800
|
}
|
|
2798
2801
|
this.isSubgraphEventDrivenGraph = this.edfsDirectiveReferences.size > 0;
|
|
2799
2802
|
if (this.isSubgraphEventDrivenGraph) {
|
|
2800
|
-
this.validateEventDrivenSubgraph(
|
|
2803
|
+
this.validateEventDrivenSubgraph();
|
|
2801
2804
|
}
|
|
2802
2805
|
for (const fieldCoords of this.unvalidatedExternalFieldCoords) {
|
|
2803
2806
|
if (this.isSubgraphVersionTwo) {
|
|
@@ -2821,7 +2824,7 @@ class NormalizationFactory {
|
|
|
2821
2824
|
concreteTypeNamesByAbstractTypeName: this.concreteTypeNamesByAbstractTypeName,
|
|
2822
2825
|
conditionalFieldDataByCoordinates: this.conditionalFieldDataByCoords,
|
|
2823
2826
|
configurationDataByTypeName: this.configurationDataByTypeName,
|
|
2824
|
-
|
|
2827
|
+
directiveDefinitionByName: this.directiveDefinitionByName,
|
|
2825
2828
|
entityDataByTypeName: this.entityDataByTypeName,
|
|
2826
2829
|
entityInterfaces: this.entityInterfaceDataByTypeName,
|
|
2827
2830
|
fieldCoordsByNamedTypeName: this.fieldCoordsByNamedTypeName,
|
|
@@ -2889,7 +2892,10 @@ function batchNormalize(subgraphs) {
|
|
|
2889
2892
|
(0, utils_3.upsertAuthorizationData)(authorizationDataByParentTypeName, authorizationData, invalidORScopesCoords);
|
|
2890
2893
|
}
|
|
2891
2894
|
for (const [namedTypeName, fieldCoords] of normalizationResult.fieldCoordsByNamedTypeName) {
|
|
2892
|
-
(0, utils_5.
|
|
2895
|
+
(0, utils_5.addIterableToSet)({
|
|
2896
|
+
source: fieldCoords,
|
|
2897
|
+
target: (0, utils_5.getValueOrDefault)(fieldCoordsByNamedTypeName, namedTypeName, () => new Set()),
|
|
2898
|
+
});
|
|
2893
2899
|
}
|
|
2894
2900
|
for (const [abstractTypeName, incomingConcreteTypeNames,] of normalizationResult.concreteTypeNamesByAbstractTypeName) {
|
|
2895
2901
|
const existingConcreteTypeNames = concreteTypeNamesByAbstractTypeName.get(abstractTypeName);
|
|
@@ -2897,7 +2903,10 @@ function batchNormalize(subgraphs) {
|
|
|
2897
2903
|
concreteTypeNamesByAbstractTypeName.set(abstractTypeName, new Set(incomingConcreteTypeNames));
|
|
2898
2904
|
continue;
|
|
2899
2905
|
}
|
|
2900
|
-
(0, utils_5.
|
|
2906
|
+
(0, utils_5.addIterableToSet)({
|
|
2907
|
+
source: incomingConcreteTypeNames,
|
|
2908
|
+
target: existingConcreteTypeNames,
|
|
2909
|
+
});
|
|
2901
2910
|
}
|
|
2902
2911
|
for (const [typeName, entityData] of normalizationResult.entityDataByTypeName) {
|
|
2903
2912
|
const keyFieldSetDataByFieldSet = entityData.keyFieldSetDatasBySubgraphName.get(subgraphName);
|
|
@@ -2916,7 +2925,7 @@ function batchNormalize(subgraphs) {
|
|
|
2916
2925
|
conditionalFieldDataByCoordinates: normalizationResult.conditionalFieldDataByCoordinates,
|
|
2917
2926
|
configurationDataByTypeName: normalizationResult.configurationDataByTypeName,
|
|
2918
2927
|
definitions: normalizationResult.subgraphAST,
|
|
2919
|
-
|
|
2928
|
+
directiveDefinitionByName: normalizationResult.directiveDefinitionByName,
|
|
2920
2929
|
entityInterfaces: normalizationResult.entityInterfaces,
|
|
2921
2930
|
isVersionTwo: normalizationResult.isVersionTwo,
|
|
2922
2931
|
keyFieldNamesByParentTypeName: normalizationResult.keyFieldNamesByParentTypeName,
|
|
@@ -2944,7 +2953,10 @@ function batchNormalize(subgraphs) {
|
|
|
2944
2953
|
else {
|
|
2945
2954
|
const overridesData = (0, utils_5.getValueOrDefault)(allOverridesByTargetSubgraphName, targetSubgraphName, () => new Map());
|
|
2946
2955
|
const existingFieldNames = (0, utils_5.getValueOrDefault)(overridesData, parentTypeName, () => new Set(fieldNames));
|
|
2947
|
-
(0, utils_5.
|
|
2956
|
+
(0, utils_5.addIterableToSet)({
|
|
2957
|
+
source: fieldNames,
|
|
2958
|
+
target: existingFieldNames,
|
|
2959
|
+
});
|
|
2948
2960
|
}
|
|
2949
2961
|
for (const fieldName of fieldNames) {
|
|
2950
2962
|
const fieldCoords = `${originalParentTypeName}.${fieldName}`;
|