@wundergraph/composition 0.37.2 → 0.38.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/errors/errors.d.ts +2 -2
- package/dist/errors/errors.js +6 -4
- package/dist/errors/errors.js.map +1 -1
- package/dist/federation/types.d.ts +10 -2
- package/dist/normalization/types.d.ts +1 -0
- package/dist/schema-building/types.d.ts +18 -14
- package/dist/schema-building/utils.d.ts +6 -4
- package/dist/schema-building/utils.js +39 -48
- package/dist/schema-building/utils.js.map +1 -1
- package/dist/subgraph/types.d.ts +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/utils/composition-version.js +1 -1
- package/dist/utils/string-constants.d.ts +1 -0
- package/dist/utils/string-constants.js +2 -0
- package/dist/utils/string-constants.js.map +1 -1
- package/dist/utils/utils.d.ts +6 -1
- package/dist/utils/utils.js +38 -0
- package/dist/utils/utils.js.map +1 -1
- package/dist/v1/federation/federation-factory.d.ts +24 -13
- package/dist/v1/federation/federation-factory.js +435 -347
- package/dist/v1/federation/federation-factory.js.map +1 -1
- package/dist/v1/normalization/normalization-factory.d.ts +6 -6
- package/dist/v1/normalization/normalization-factory.js +66 -52
- package/dist/v1/normalization/normalization-factory.js.map +1 -1
- package/dist/v1/normalization/utils.d.ts +1 -1
- package/dist/v1/normalization/utils.js +3 -1
- package/dist/v1/normalization/utils.js.map +1 -1
- package/dist/v1/normalization/walkers.js +17 -24
- package/dist/v1/normalization/walkers.js.map +1 -1
- package/dist/v1/schema-building/type-merging.d.ts +1 -1
- package/dist/v1/utils/utils.d.ts +0 -2
- package/dist/v1/utils/utils.js +0 -12
- package/dist/v1/utils/utils.js.map +1 -1
- package/package.json +2 -2
|
@@ -28,12 +28,13 @@ class FederationFactory {
|
|
|
28
28
|
concreteTypeNamesByAbstractTypeName;
|
|
29
29
|
clientDefinitions = [constants_1.DEPRECATED_DEFINITION];
|
|
30
30
|
currentSubgraphName = '';
|
|
31
|
-
|
|
31
|
+
subgraphNamesByNamedTypeNameByFieldCoords = new Map();
|
|
32
32
|
entityDataByTypeName;
|
|
33
33
|
entityInterfaceFederationDataByTypeName;
|
|
34
34
|
errors = [];
|
|
35
|
-
|
|
36
|
-
|
|
35
|
+
fieldConfigurationByFieldCoords = new Map();
|
|
36
|
+
inaccessibleCoords = new Set();
|
|
37
|
+
inaccessibleRequiredInputValueErrorByCoords = new Map();
|
|
37
38
|
isMaxDepth = false;
|
|
38
39
|
internalGraph;
|
|
39
40
|
internalSubgraphBySubgraphName;
|
|
@@ -43,7 +44,7 @@ class FederationFactory {
|
|
|
43
44
|
namedOutputTypeNames = new Set();
|
|
44
45
|
parentDefinitionDataByTypeName = new Map();
|
|
45
46
|
parentTagDataByTypeName = new Map();
|
|
46
|
-
|
|
47
|
+
coordsByNamedTypeName = new Map();
|
|
47
48
|
persistedDirectiveDefinitionByDirectiveName = new Map([
|
|
48
49
|
[string_constants_2.AUTHENTICATED, constants_1.AUTHENTICATED_DEFINITION],
|
|
49
50
|
[string_constants_2.DEPRECATED, constants_1.DEPRECATED_DEFINITION],
|
|
@@ -54,9 +55,8 @@ class FederationFactory {
|
|
|
54
55
|
persistedDirectiveDefinitions = new Set([string_constants_2.AUTHENTICATED, string_constants_2.DEPRECATED, string_constants_2.INACCESSIBLE, string_constants_2.TAG, string_constants_2.REQUIRES_SCOPES]);
|
|
55
56
|
potentialPersistedDirectiveDefinitionDataByDirectiveName = new Map();
|
|
56
57
|
routerDefinitions = [constants_1.DEPRECATED_DEFINITION, constants_1.TAG_DEFINITION];
|
|
57
|
-
shareableErrorTypeNames = new Map();
|
|
58
58
|
subscriptionFilterDataByFieldPath = new Map();
|
|
59
|
-
|
|
59
|
+
tagNamesByCoords = new Map();
|
|
60
60
|
warnings;
|
|
61
61
|
constructor(params) {
|
|
62
62
|
this.authorizationDataByParentTypeName = params.authorizationDataByParentTypeName;
|
|
@@ -225,7 +225,7 @@ class FederationFactory {
|
|
|
225
225
|
addValidPrimaryKeyTargetsFromInterfaceObject(internalSubgraph, interfaceObjectTypeName, entityData, graphNode) {
|
|
226
226
|
const parentDefinitionDataByTypeName = internalSubgraph.parentDefinitionDataByTypeName;
|
|
227
227
|
const interfaceObjectData = parentDefinitionDataByTypeName.get(interfaceObjectTypeName);
|
|
228
|
-
if (!interfaceObjectData ||
|
|
228
|
+
if (!interfaceObjectData || !(0, utils_5.isParentDataCompositeOutputType)(interfaceObjectData)) {
|
|
229
229
|
throw (0, errors_1.incompatibleParentKindFatalError)(interfaceObjectTypeName, graphql_1.Kind.INTERFACE_TYPE_DEFINITION, interfaceObjectData?.kind || graphql_1.Kind.NULL);
|
|
230
230
|
}
|
|
231
231
|
const configurationData = (0, utils_6.getOrThrowError)(internalSubgraph.configurationDataByTypeName, entityData.typeName, 'internalSubgraph.configurationDataByTypeName');
|
|
@@ -267,7 +267,7 @@ class FederationFactory {
|
|
|
267
267
|
return utils_5.MergeMethod.UNION;
|
|
268
268
|
}
|
|
269
269
|
generateTagData() {
|
|
270
|
-
for (const [path, tagNames] of this.
|
|
270
|
+
for (const [path, tagNames] of this.tagNamesByCoords) {
|
|
271
271
|
const paths = path.split('.');
|
|
272
272
|
if (paths.length < 1) {
|
|
273
273
|
continue;
|
|
@@ -302,100 +302,93 @@ class FederationFactory {
|
|
|
302
302
|
}
|
|
303
303
|
upsertEnumValueData(enumValueDataByValueName, incomingData, isParentInaccessible) {
|
|
304
304
|
const existingData = enumValueDataByValueName.get(incomingData.name);
|
|
305
|
-
const
|
|
306
|
-
|
|
307
|
-
(0, utils_5.
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
this.recordTagNamesByPath(baseData, enumValuePath);
|
|
305
|
+
const targetData = existingData || this.copyEnumValueData(incomingData);
|
|
306
|
+
(0, utils_5.extractPersistedDirectives)(targetData.persistedDirectivesData, incomingData.directivesByDirectiveName, this.persistedDirectiveDefinitionByDirectiveName);
|
|
307
|
+
const isValueInaccessible = (0, utils_5.isNodeDataInaccessible)(incomingData);
|
|
308
|
+
if (isParentInaccessible || isValueInaccessible) {
|
|
309
|
+
this.inaccessibleCoords.add(targetData.federatedCoords);
|
|
310
|
+
}
|
|
311
|
+
this.recordTagNamesByCoords(targetData, targetData.federatedCoords);
|
|
313
312
|
if (!existingData) {
|
|
314
|
-
|
|
315
|
-
directives: [],
|
|
316
|
-
kind: incomingData.node.kind,
|
|
317
|
-
name: (0, utils_1.stringToNameNode)(incomingData.name),
|
|
318
|
-
};
|
|
319
|
-
enumValueDataByValueName.set(incomingData.name, incomingData);
|
|
313
|
+
enumValueDataByValueName.set(targetData.name, targetData);
|
|
320
314
|
return;
|
|
321
315
|
}
|
|
322
|
-
|
|
323
|
-
(0,
|
|
324
|
-
(0, utils_5.setLongestDescription)(
|
|
325
|
-
(0, utils_6.addIterableValuesToSet)(incomingData.subgraphNames,
|
|
316
|
+
targetData.appearances += 1;
|
|
317
|
+
(0, utils_6.addNewObjectValueMapEntries)(incomingData.configureDescriptionDataBySubgraphName, targetData.configureDescriptionDataBySubgraphName);
|
|
318
|
+
(0, utils_5.setLongestDescription)(targetData, incomingData);
|
|
319
|
+
(0, utils_6.addIterableValuesToSet)(incomingData.subgraphNames, targetData.subgraphNames);
|
|
326
320
|
}
|
|
327
321
|
// To facilitate the splitting of tag paths, field arguments do not use the renamedPath property for tagNamesByPath
|
|
328
|
-
upsertInputValueData(inputValueDataByValueName, incomingData,
|
|
322
|
+
upsertInputValueData(inputValueDataByValueName, incomingData, parentCoords, isParentInaccessible) {
|
|
329
323
|
const existingData = inputValueDataByValueName.get(incomingData.name);
|
|
330
|
-
const
|
|
331
|
-
(0, utils_5.extractPersistedDirectives)(
|
|
332
|
-
this.
|
|
324
|
+
const targetData = existingData || this.copyInputValueData(incomingData);
|
|
325
|
+
(0, utils_5.extractPersistedDirectives)(targetData.persistedDirectivesData, incomingData.directivesByDirectiveName, this.persistedDirectiveDefinitionByDirectiveName);
|
|
326
|
+
this.recordTagNamesByCoords(targetData, `${parentCoords}.${targetData.name}`);
|
|
327
|
+
this.namedInputValueTypeNames.add(targetData.namedTypeName);
|
|
328
|
+
(0, utils_6.getValueOrDefault)(this.coordsByNamedTypeName, targetData.namedTypeName, () => new Set()).add(targetData.federatedCoords);
|
|
333
329
|
if (!existingData) {
|
|
334
|
-
|
|
335
|
-
directives: [],
|
|
336
|
-
kind: incomingData.node.kind,
|
|
337
|
-
name: (0, utils_1.stringToNameNode)(incomingData.name),
|
|
338
|
-
type: incomingData.type,
|
|
339
|
-
};
|
|
340
|
-
inputValueDataByValueName.set(incomingData.name, incomingData);
|
|
330
|
+
inputValueDataByValueName.set(targetData.name, targetData);
|
|
341
331
|
return;
|
|
342
332
|
}
|
|
343
|
-
(0,
|
|
344
|
-
(0, utils_5.setLongestDescription)(
|
|
345
|
-
(0, utils_6.addIterableValuesToSet)(incomingData.requiredSubgraphNames,
|
|
346
|
-
(0, utils_6.addIterableValuesToSet)(incomingData.subgraphNames,
|
|
333
|
+
(0, utils_6.addNewObjectValueMapEntries)(incomingData.configureDescriptionDataBySubgraphName, targetData.configureDescriptionDataBySubgraphName);
|
|
334
|
+
(0, utils_5.setLongestDescription)(targetData, incomingData);
|
|
335
|
+
(0, utils_6.addIterableValuesToSet)(incomingData.requiredSubgraphNames, targetData.requiredSubgraphNames);
|
|
336
|
+
(0, utils_6.addIterableValuesToSet)(incomingData.subgraphNames, targetData.subgraphNames);
|
|
337
|
+
this.handleInputValueInaccessibility(isParentInaccessible, targetData, parentCoords);
|
|
347
338
|
// TODO refactor type merging
|
|
348
|
-
const { typeErrors, typeNode } = (0, type_merging_1.getMostRestrictiveMergedTypeNode)(
|
|
339
|
+
const { typeErrors, typeNode } = (0, type_merging_1.getMostRestrictiveMergedTypeNode)(targetData.type, incomingData.type, targetData.originalCoords, this.errors);
|
|
349
340
|
if (typeNode) {
|
|
350
|
-
|
|
341
|
+
targetData.type = typeNode;
|
|
351
342
|
}
|
|
352
343
|
else {
|
|
353
344
|
if (!typeErrors || typeErrors.length < 2) {
|
|
354
|
-
throw (0, errors_1.fieldTypeMergeFatalError)(
|
|
345
|
+
throw (0, errors_1.fieldTypeMergeFatalError)(targetData.name);
|
|
355
346
|
}
|
|
356
347
|
existingData.isArgument
|
|
357
|
-
? this.errors.push((0, errors_1.incompatibleArgumentTypesError)(
|
|
358
|
-
: this.errors.push((0, errors_1.incompatibleChildTypesError)(
|
|
348
|
+
? this.errors.push((0, errors_1.incompatibleArgumentTypesError)(targetData.name, targetData.federatedCoords, typeErrors[0], typeErrors[1]))
|
|
349
|
+
: this.errors.push((0, errors_1.incompatibleChildTypesError)(targetData.federatedCoords, typeErrors[0], typeErrors[1]));
|
|
359
350
|
}
|
|
360
|
-
(0, utils_5.compareAndValidateInputValueDefaultValues)(
|
|
351
|
+
(0, utils_5.compareAndValidateInputValueDefaultValues)(targetData, incomingData, this.errors);
|
|
361
352
|
}
|
|
362
|
-
|
|
363
|
-
/* If
|
|
364
|
-
|
|
365
|
-
|
|
353
|
+
handleInputValueInaccessibility(isParentInaccessible, inputValueData, parentCoords) {
|
|
354
|
+
/* If an ancestor (Input Object for field; Composite type or field for argument) of the input value is
|
|
355
|
+
* @inaccessible, nullability is not considered.
|
|
356
|
+
* However, if only the input value (field or argument) itself is @inaccessible, an error is returned.
|
|
357
|
+
*/
|
|
366
358
|
if (isParentInaccessible) {
|
|
367
|
-
this.
|
|
359
|
+
this.inaccessibleRequiredInputValueErrorByCoords.delete(inputValueData.federatedCoords);
|
|
360
|
+
this.inaccessibleCoords.add(inputValueData.federatedCoords);
|
|
368
361
|
return;
|
|
369
362
|
}
|
|
370
363
|
if (!(0, utils_5.isNodeDataInaccessible)(inputValueData)) {
|
|
371
364
|
return;
|
|
372
365
|
}
|
|
373
366
|
if ((0, utils_5.isTypeRequired)(inputValueData.type)) {
|
|
374
|
-
this.
|
|
375
|
-
|
|
376
|
-
else {
|
|
377
|
-
this.inaccessiblePaths.add(argumentPath);
|
|
367
|
+
this.inaccessibleRequiredInputValueErrorByCoords.set(inputValueData.federatedCoords, (0, errors_1.inaccessibleRequiredInputValueError)(inputValueData, parentCoords));
|
|
368
|
+
return;
|
|
378
369
|
}
|
|
370
|
+
this.inaccessibleCoords.add(inputValueData.federatedCoords);
|
|
379
371
|
}
|
|
380
|
-
handleSubscriptionFilterDirective(incomingData,
|
|
372
|
+
handleSubscriptionFilterDirective(incomingData, targetData) {
|
|
381
373
|
const subscriptionFilters = incomingData.directivesByDirectiveName.get(string_constants_2.SUBSCRIPTION_FILTER);
|
|
382
|
-
if (subscriptionFilters) {
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
this.subscriptionFilterDataByFieldPath.set(fieldPath, {
|
|
391
|
-
directive: subscriptionFilters[0],
|
|
392
|
-
fieldData: baseData || incomingData,
|
|
393
|
-
directiveSubgraphName: subgraphName,
|
|
394
|
-
});
|
|
374
|
+
if (!subscriptionFilters) {
|
|
375
|
+
return;
|
|
376
|
+
}
|
|
377
|
+
// There should only be a single entry in the set
|
|
378
|
+
const subgraphName = (0, utils_6.getSingleSetEntry)(incomingData.subgraphNames);
|
|
379
|
+
if (subgraphName === undefined) {
|
|
380
|
+
this.errors.push((0, errors_1.unknownFieldSubgraphNameError)(incomingData.federatedCoords));
|
|
381
|
+
return;
|
|
395
382
|
}
|
|
383
|
+
// @openfed__subscriptionFilter is non-repeatable
|
|
384
|
+
this.subscriptionFilterDataByFieldPath.set(incomingData.federatedCoords, {
|
|
385
|
+
directive: subscriptionFilters[0],
|
|
386
|
+
fieldData: targetData || incomingData,
|
|
387
|
+
directiveSubgraphName: subgraphName,
|
|
388
|
+
});
|
|
396
389
|
}
|
|
397
|
-
federateOutputType({ current, other,
|
|
398
|
-
other = (0, ast_1.getMutableTypeNode)(other,
|
|
390
|
+
federateOutputType({ current, other, coords, mostRestrictive }) {
|
|
391
|
+
other = (0, ast_1.getMutableTypeNode)(other, coords, this.errors); // current is already a deep copy
|
|
399
392
|
// The first type of the pair to diverge in restriction takes precedence in all future differences.
|
|
400
393
|
// If the other type of the pair also diverges, it's a src error.
|
|
401
394
|
// To keep the output link intact, it is not possible to spread assign "lastTypeNode".
|
|
@@ -427,7 +420,7 @@ class FederationFactory {
|
|
|
427
420
|
}
|
|
428
421
|
if (current.kind === graphql_1.Kind.NON_NULL_TYPE) {
|
|
429
422
|
if (divergentType === type_merging_1.DivergentType.OTHER) {
|
|
430
|
-
this.errors.push((0, errors_1.incompatibleChildTypesError)(
|
|
423
|
+
this.errors.push((0, errors_1.incompatibleChildTypesError)(coords, current.kind, other.kind));
|
|
431
424
|
return { success: false };
|
|
432
425
|
}
|
|
433
426
|
else {
|
|
@@ -443,7 +436,7 @@ class FederationFactory {
|
|
|
443
436
|
}
|
|
444
437
|
if (other.kind === graphql_1.Kind.NON_NULL_TYPE) {
|
|
445
438
|
if (divergentType === type_merging_1.DivergentType.CURRENT) {
|
|
446
|
-
this.errors.push((0, errors_1.incompatibleChildTypesError)(
|
|
439
|
+
this.errors.push((0, errors_1.incompatibleChildTypesError)(coords, current.kind, other.kind));
|
|
447
440
|
return { success: false };
|
|
448
441
|
}
|
|
449
442
|
else {
|
|
@@ -458,79 +451,52 @@ class FederationFactory {
|
|
|
458
451
|
continue;
|
|
459
452
|
}
|
|
460
453
|
// At least one of the types must be a non-null wrapper, or the types are inconsistent
|
|
461
|
-
this.errors.push((0, errors_1.incompatibleChildTypesError)(
|
|
454
|
+
this.errors.push((0, errors_1.incompatibleChildTypesError)(coords, current.kind, other.kind));
|
|
462
455
|
return { success: false };
|
|
463
456
|
}
|
|
464
|
-
this.errors.push((0, errors_1.maximumTypeNestingExceededError)(
|
|
457
|
+
this.errors.push((0, errors_1.maximumTypeNestingExceededError)(coords));
|
|
465
458
|
return { success: false };
|
|
466
459
|
}
|
|
467
460
|
addSubgraphNameToExistingFieldNamedTypeDisparity(incomingData) {
|
|
468
|
-
const subgraphNamesByNamedTypeName = this.
|
|
461
|
+
const subgraphNamesByNamedTypeName = this.subgraphNamesByNamedTypeNameByFieldCoords.get(incomingData.federatedCoords);
|
|
469
462
|
if (!subgraphNamesByNamedTypeName) {
|
|
470
463
|
return;
|
|
471
464
|
}
|
|
472
465
|
(0, utils_6.addIterableValuesToSet)(incomingData.subgraphNames, (0, utils_6.getValueOrDefault)(subgraphNamesByNamedTypeName, incomingData.namedTypeName, () => new Set()));
|
|
473
466
|
}
|
|
474
467
|
upsertFieldData(fieldDataByFieldName, incomingData, isParentInaccessible) {
|
|
475
|
-
const fieldPath = `${incomingData.renamedParentTypeName}.${incomingData.name}`;
|
|
476
|
-
(0, utils_6.getValueOrDefault)(this.pathsByNamedTypeName, incomingData.namedTypeName, () => new Set()).add(fieldPath);
|
|
477
|
-
this.namedOutputTypeNames.add(incomingData.namedTypeName);
|
|
478
468
|
const existingData = fieldDataByFieldName.get(incomingData.name);
|
|
479
|
-
const
|
|
480
|
-
this.
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
469
|
+
const targetData = existingData || this.copyFieldData(incomingData, isParentInaccessible || (0, utils_5.isNodeDataInaccessible)(incomingData));
|
|
470
|
+
(0, utils_6.getValueOrDefault)(this.coordsByNamedTypeName, incomingData.namedTypeName, () => new Set()).add(targetData.federatedCoords);
|
|
471
|
+
this.namedOutputTypeNames.add(incomingData.namedTypeName);
|
|
472
|
+
this.handleSubscriptionFilterDirective(incomingData, targetData);
|
|
473
|
+
(0, utils_5.extractPersistedDirectives)(targetData.persistedDirectivesData, incomingData.directivesByDirectiveName, this.persistedDirectiveDefinitionByDirectiveName);
|
|
474
|
+
const isFieldInaccessible = isParentInaccessible || (0, utils_5.isNodeDataInaccessible)(targetData);
|
|
475
|
+
if (isFieldInaccessible) {
|
|
476
|
+
this.inaccessibleCoords.add(targetData.federatedCoords);
|
|
477
|
+
}
|
|
478
|
+
this.recordTagNamesByCoords(targetData, targetData.federatedCoords);
|
|
487
479
|
if (!existingData) {
|
|
488
|
-
|
|
489
|
-
fieldDataByFieldName.set(incomingData.name, incomingData);
|
|
490
|
-
incomingData.node = {
|
|
491
|
-
arguments: [],
|
|
492
|
-
directives: [],
|
|
493
|
-
kind: incomingData.node.kind,
|
|
494
|
-
name: (0, utils_1.stringToNameNode)(incomingData.name),
|
|
495
|
-
type: incomingData.type,
|
|
496
|
-
};
|
|
497
|
-
for (const [argumentName, inputValueData] of incomingData.argumentDataByArgumentName) {
|
|
498
|
-
inputValueData.description = this.getInitialNodeDescription(inputValueData);
|
|
499
|
-
inputValueData.node = {
|
|
500
|
-
directives: [],
|
|
501
|
-
kind: inputValueData.node.kind,
|
|
502
|
-
name: (0, utils_1.stringToNameNode)(inputValueData.name),
|
|
503
|
-
type: inputValueData.type,
|
|
504
|
-
};
|
|
505
|
-
const namedArgumentTypeName = (0, ast_1.getTypeNodeNamedTypeName)(inputValueData.type);
|
|
506
|
-
(0, utils_6.getValueOrDefault)(this.pathsByNamedTypeName, namedArgumentTypeName, () => new Set()).add(inputValueData.renamedPath);
|
|
507
|
-
this.namedInputValueTypeNames.add(namedArgumentTypeName);
|
|
508
|
-
(0, utils_5.extractPersistedDirectives)(inputValueData.persistedDirectivesData, inputValueData.directivesByDirectiveName, this.persistedDirectiveDefinitionByDirectiveName);
|
|
509
|
-
/* If either the parent or the field to which the field belongs are declared inaccessible, the nullability
|
|
510
|
-
** of the argument is not considered. However, if only the argument is declared inaccessible, it is an
|
|
511
|
-
** error. */
|
|
512
|
-
this.handleArgumentInaccessibility(isParentInaccessible || isFieldInaccessible, inputValueData, inputValueData.renamedPath, fieldPath);
|
|
513
|
-
this.recordTagNamesByPath(inputValueData, `${fieldPath}.${argumentName}`);
|
|
514
|
-
}
|
|
480
|
+
fieldDataByFieldName.set(targetData.name, targetData);
|
|
515
481
|
return;
|
|
516
482
|
}
|
|
517
483
|
const result = this.federateOutputType({
|
|
518
|
-
current:
|
|
484
|
+
current: targetData.type,
|
|
519
485
|
other: incomingData.type,
|
|
520
|
-
|
|
486
|
+
coords: targetData.federatedCoords,
|
|
521
487
|
mostRestrictive: false,
|
|
522
488
|
});
|
|
523
489
|
if (result.success) {
|
|
524
|
-
|
|
525
|
-
if (
|
|
526
|
-
const subgraphNamesByNamedTypeName = (0, utils_6.getValueOrDefault)(this.
|
|
490
|
+
targetData.type = result.typeNode;
|
|
491
|
+
if (targetData.namedTypeName !== incomingData.namedTypeName) {
|
|
492
|
+
const subgraphNamesByNamedTypeName = (0, utils_6.getValueOrDefault)(this.subgraphNamesByNamedTypeNameByFieldCoords, targetData.federatedCoords, () => new Map());
|
|
527
493
|
/* Only propagate the subgraph names of the existing data if it has never been propagated before.
|
|
528
494
|
* This is to prevent the propagation of subgraph names where that named type is not returned.
|
|
529
495
|
*/
|
|
530
|
-
const existingSubgraphNames = (0, utils_6.getValueOrDefault)(subgraphNamesByNamedTypeName,
|
|
496
|
+
const existingSubgraphNames = (0, utils_6.getValueOrDefault)(subgraphNamesByNamedTypeName, targetData.namedTypeName, () => new Set());
|
|
531
497
|
if (existingSubgraphNames.size < 1) {
|
|
532
498
|
// Add all subgraph names that are not the subgraph name in the incoming data
|
|
533
|
-
for (const subgraphName of
|
|
499
|
+
for (const subgraphName of targetData.subgraphNames) {
|
|
534
500
|
if (!incomingData.subgraphNames.has(subgraphName)) {
|
|
535
501
|
existingSubgraphNames.add(subgraphName);
|
|
536
502
|
}
|
|
@@ -545,220 +511,348 @@ class FederationFactory {
|
|
|
545
511
|
this.addSubgraphNameToExistingFieldNamedTypeDisparity(incomingData);
|
|
546
512
|
}
|
|
547
513
|
}
|
|
548
|
-
for (const
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
}
|
|
558
|
-
(0, utils_3.addMapEntries)(incomingData.configureDescriptionDataBySubgraphName, existingData.configureDescriptionDataBySubgraphName);
|
|
559
|
-
(0, utils_5.setLongestDescription)(existingData, incomingData);
|
|
560
|
-
existingData.isInaccessible ||= incomingData.isInaccessible;
|
|
561
|
-
(0, utils_3.addMapEntries)(incomingData.externalFieldDataBySubgraphName, existingData.externalFieldDataBySubgraphName);
|
|
562
|
-
(0, utils_3.addMapEntries)(incomingData.isShareableBySubgraphName, existingData.isShareableBySubgraphName);
|
|
563
|
-
(0, utils_6.addIterableValuesToSet)(incomingData.subgraphNames, existingData.subgraphNames);
|
|
514
|
+
for (const inputValueData of incomingData.argumentDataByArgumentName.values()) {
|
|
515
|
+
this.upsertInputValueData(targetData.argumentDataByArgumentName, inputValueData, targetData.federatedCoords, isFieldInaccessible);
|
|
516
|
+
}
|
|
517
|
+
(0, utils_6.addNewObjectValueMapEntries)(incomingData.configureDescriptionDataBySubgraphName, existingData.configureDescriptionDataBySubgraphName);
|
|
518
|
+
(0, utils_5.setLongestDescription)(targetData, incomingData);
|
|
519
|
+
targetData.isInaccessible ||= incomingData.isInaccessible;
|
|
520
|
+
(0, utils_6.addNewObjectValueMapEntries)(incomingData.externalFieldDataBySubgraphName, targetData.externalFieldDataBySubgraphName);
|
|
521
|
+
(0, utils_6.addMapEntries)(incomingData.isShareableBySubgraphName, targetData.isShareableBySubgraphName);
|
|
522
|
+
(0, utils_6.addIterableValuesToSet)(incomingData.subgraphNames, targetData.subgraphNames);
|
|
564
523
|
}
|
|
565
524
|
getClientSchemaUnionMembers(unionData) {
|
|
566
525
|
const members = [];
|
|
567
526
|
for (const [memberName, namedTypeNode] of unionData.memberByMemberTypeName) {
|
|
568
|
-
if (!this.
|
|
527
|
+
if (!this.inaccessibleCoords.has(memberName)) {
|
|
569
528
|
members.push(namedTypeNode);
|
|
570
529
|
}
|
|
571
530
|
}
|
|
572
531
|
return members;
|
|
573
532
|
}
|
|
574
|
-
|
|
575
|
-
const path =
|
|
576
|
-
if (data.persistedDirectivesData.
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
533
|
+
recordTagNamesByCoords(data, coords) {
|
|
534
|
+
const path = coords || data.name;
|
|
535
|
+
if (data.persistedDirectivesData.tagDirectiveByName.size < 1) {
|
|
536
|
+
return;
|
|
537
|
+
}
|
|
538
|
+
const tagNames = (0, utils_6.getValueOrDefault)(this.tagNamesByCoords, path, () => new Set());
|
|
539
|
+
for (const tagName of data.persistedDirectivesData.tagDirectiveByName.keys()) {
|
|
540
|
+
tagNames.add(tagName);
|
|
541
|
+
}
|
|
542
|
+
}
|
|
543
|
+
copyMutualParentDefinitionData(sourceData) {
|
|
544
|
+
return {
|
|
545
|
+
configureDescriptionDataBySubgraphName: (0, utils_6.copyObjectValueMap)(sourceData.configureDescriptionDataBySubgraphName),
|
|
546
|
+
directivesByDirectiveName: (0, utils_6.copyArrayValueMap)(sourceData.directivesByDirectiveName),
|
|
547
|
+
extensionType: sourceData.extensionType,
|
|
548
|
+
name: sourceData.name,
|
|
549
|
+
persistedDirectivesData: (0, utils_5.extractPersistedDirectives)((0, utils_5.newPersistedDirectivesData)(), sourceData.directivesByDirectiveName, this.persistedDirectiveDefinitionByDirectiveName),
|
|
550
|
+
description: (0, utils_5.getInitialFederatedDescription)(sourceData),
|
|
551
|
+
};
|
|
552
|
+
}
|
|
553
|
+
copyEnumValueData(sourceData) {
|
|
554
|
+
return {
|
|
555
|
+
appearances: sourceData.appearances,
|
|
556
|
+
configureDescriptionDataBySubgraphName: (0, utils_6.copyObjectValueMap)(sourceData.configureDescriptionDataBySubgraphName),
|
|
557
|
+
federatedCoords: sourceData.federatedCoords,
|
|
558
|
+
directivesByDirectiveName: (0, utils_6.copyArrayValueMap)(sourceData.directivesByDirectiveName),
|
|
559
|
+
kind: sourceData.kind,
|
|
560
|
+
name: sourceData.name,
|
|
561
|
+
node: {
|
|
562
|
+
directives: [],
|
|
563
|
+
kind: sourceData.kind,
|
|
564
|
+
name: (0, utils_1.stringToNameNode)(sourceData.name),
|
|
565
|
+
},
|
|
566
|
+
parentTypeName: sourceData.parentTypeName,
|
|
567
|
+
persistedDirectivesData: (0, utils_5.extractPersistedDirectives)((0, utils_5.newPersistedDirectivesData)(), sourceData.directivesByDirectiveName, this.persistedDirectiveDefinitionByDirectiveName),
|
|
568
|
+
subgraphNames: new Set(sourceData.subgraphNames),
|
|
569
|
+
description: (0, utils_5.getInitialFederatedDescription)(sourceData),
|
|
570
|
+
};
|
|
571
|
+
}
|
|
572
|
+
copyInputValueData(sourceData) {
|
|
573
|
+
return {
|
|
574
|
+
configureDescriptionDataBySubgraphName: (0, utils_6.copyObjectValueMap)(sourceData.configureDescriptionDataBySubgraphName),
|
|
575
|
+
directivesByDirectiveName: (0, utils_6.copyArrayValueMap)(sourceData.directivesByDirectiveName),
|
|
576
|
+
includeDefaultValue: sourceData.includeDefaultValue,
|
|
577
|
+
isArgument: sourceData.isArgument,
|
|
578
|
+
kind: sourceData.kind,
|
|
579
|
+
name: sourceData.name,
|
|
580
|
+
namedTypeName: sourceData.namedTypeName,
|
|
581
|
+
node: {
|
|
582
|
+
directives: [],
|
|
583
|
+
kind: graphql_1.Kind.INPUT_VALUE_DEFINITION,
|
|
584
|
+
name: (0, utils_1.stringToNameNode)(sourceData.name),
|
|
585
|
+
type: sourceData.type,
|
|
586
|
+
},
|
|
587
|
+
originalCoords: sourceData.originalCoords,
|
|
588
|
+
persistedDirectivesData: (0, utils_5.extractPersistedDirectives)((0, utils_5.newPersistedDirectivesData)(), sourceData.directivesByDirectiveName, this.persistedDirectiveDefinitionByDirectiveName),
|
|
589
|
+
federatedCoords: sourceData.federatedCoords,
|
|
590
|
+
requiredSubgraphNames: new Set(sourceData.requiredSubgraphNames),
|
|
591
|
+
subgraphNames: new Set(sourceData.subgraphNames),
|
|
592
|
+
type: sourceData.type,
|
|
593
|
+
defaultValue: sourceData.defaultValue,
|
|
594
|
+
description: (0, utils_5.getInitialFederatedDescription)(sourceData),
|
|
595
|
+
};
|
|
596
|
+
}
|
|
597
|
+
copyInputValueDataByValueName(source, isParentInaccessible, parentCoords) {
|
|
598
|
+
const inputValueDataByInputValueName = new Map();
|
|
599
|
+
for (const [inputValueName, sourceData] of source) {
|
|
600
|
+
const targetData = this.copyInputValueData(sourceData);
|
|
601
|
+
this.handleInputValueInaccessibility(isParentInaccessible, targetData, parentCoords);
|
|
602
|
+
(0, utils_6.getValueOrDefault)(this.coordsByNamedTypeName, targetData.namedTypeName, () => new Set()).add(targetData.federatedCoords);
|
|
603
|
+
this.namedInputValueTypeNames.add(targetData.namedTypeName);
|
|
604
|
+
this.recordTagNamesByCoords(targetData, `${parentCoords}.${sourceData.name}`);
|
|
605
|
+
inputValueDataByInputValueName.set(inputValueName, targetData);
|
|
606
|
+
}
|
|
607
|
+
return inputValueDataByInputValueName;
|
|
608
|
+
}
|
|
609
|
+
copyFieldData(sourceData, isInaccessible) {
|
|
610
|
+
return {
|
|
611
|
+
argumentDataByArgumentName: this.copyInputValueDataByValueName(sourceData.argumentDataByArgumentName, isInaccessible, sourceData.federatedCoords),
|
|
612
|
+
configureDescriptionDataBySubgraphName: (0, utils_6.copyObjectValueMap)(sourceData.configureDescriptionDataBySubgraphName),
|
|
613
|
+
directivesByDirectiveName: (0, utils_6.copyArrayValueMap)(sourceData.directivesByDirectiveName),
|
|
614
|
+
externalFieldDataBySubgraphName: (0, utils_6.copyObjectValueMap)(sourceData.externalFieldDataBySubgraphName),
|
|
615
|
+
federatedCoords: sourceData.federatedCoords,
|
|
616
|
+
isInaccessible: sourceData.isInaccessible,
|
|
617
|
+
isShareableBySubgraphName: new Map(sourceData.isShareableBySubgraphName),
|
|
618
|
+
kind: sourceData.kind,
|
|
619
|
+
name: sourceData.name,
|
|
620
|
+
namedTypeName: sourceData.namedTypeName,
|
|
621
|
+
node: {
|
|
622
|
+
arguments: [],
|
|
623
|
+
directives: [],
|
|
624
|
+
kind: sourceData.kind,
|
|
625
|
+
name: (0, utils_1.stringToNameNode)(sourceData.name),
|
|
626
|
+
type: sourceData.type,
|
|
627
|
+
},
|
|
628
|
+
originalParentTypeName: sourceData.originalParentTypeName,
|
|
629
|
+
persistedDirectivesData: (0, utils_5.extractPersistedDirectives)((0, utils_5.newPersistedDirectivesData)(), sourceData.directivesByDirectiveName, this.persistedDirectiveDefinitionByDirectiveName),
|
|
630
|
+
renamedParentTypeName: sourceData.renamedParentTypeName,
|
|
631
|
+
subgraphNames: new Set(sourceData.subgraphNames),
|
|
632
|
+
type: sourceData.type,
|
|
633
|
+
description: (0, utils_5.getInitialFederatedDescription)(sourceData),
|
|
634
|
+
};
|
|
635
|
+
}
|
|
636
|
+
copyEnumValueDataByValueName(source, isParentInaccessible) {
|
|
637
|
+
const output = new Map();
|
|
638
|
+
for (const [childName, sourceData] of source) {
|
|
639
|
+
const targetData = this.copyEnumValueData(sourceData);
|
|
640
|
+
this.recordTagNamesByCoords(targetData, targetData.federatedCoords);
|
|
641
|
+
if (isParentInaccessible || (0, utils_5.isNodeDataInaccessible)(targetData)) {
|
|
642
|
+
this.inaccessibleCoords.add(targetData.federatedCoords);
|
|
643
|
+
}
|
|
644
|
+
output.set(childName, targetData);
|
|
645
|
+
}
|
|
646
|
+
return output;
|
|
647
|
+
}
|
|
648
|
+
copyFieldDataByFieldName(source, isParentInaccessible) {
|
|
649
|
+
const fieldDataByFieldName = new Map();
|
|
650
|
+
for (const [fieldName, sourceData] of source) {
|
|
651
|
+
const isFieldInaccessible = isParentInaccessible || (0, utils_5.isNodeDataInaccessible)(sourceData);
|
|
652
|
+
const targetData = this.copyFieldData(sourceData, isFieldInaccessible);
|
|
653
|
+
this.handleSubscriptionFilterDirective(targetData);
|
|
654
|
+
(0, utils_6.getValueOrDefault)(this.coordsByNamedTypeName, targetData.namedTypeName, () => new Set()).add(targetData.federatedCoords);
|
|
655
|
+
this.namedOutputTypeNames.add(targetData.namedTypeName);
|
|
656
|
+
this.recordTagNamesByCoords(targetData, targetData.federatedCoords);
|
|
657
|
+
if (isFieldInaccessible) {
|
|
658
|
+
this.inaccessibleCoords.add(targetData.federatedCoords);
|
|
659
|
+
}
|
|
660
|
+
fieldDataByFieldName.set(fieldName, targetData);
|
|
661
|
+
}
|
|
662
|
+
return fieldDataByFieldName;
|
|
663
|
+
}
|
|
664
|
+
copyParentDefinitionData(sourceData) {
|
|
665
|
+
const data = this.copyMutualParentDefinitionData(sourceData);
|
|
666
|
+
switch (sourceData.kind) {
|
|
667
|
+
case graphql_1.Kind.ENUM_TYPE_DEFINITION: {
|
|
668
|
+
return {
|
|
669
|
+
...data,
|
|
670
|
+
appearances: sourceData.appearances,
|
|
671
|
+
enumValueDataByValueName: this.copyEnumValueDataByValueName(sourceData.enumValueDataByValueName, sourceData.isInaccessible),
|
|
672
|
+
isInaccessible: sourceData.isInaccessible,
|
|
673
|
+
kind: sourceData.kind,
|
|
674
|
+
node: {
|
|
675
|
+
kind: sourceData.kind,
|
|
676
|
+
name: (0, utils_1.stringToNameNode)(sourceData.name),
|
|
677
|
+
},
|
|
678
|
+
subgraphNames: new Set(sourceData.subgraphNames),
|
|
679
|
+
};
|
|
680
|
+
}
|
|
681
|
+
case graphql_1.Kind.INPUT_OBJECT_TYPE_DEFINITION: {
|
|
682
|
+
return {
|
|
683
|
+
...data,
|
|
684
|
+
inputValueDataByValueName: this.copyInputValueDataByValueName(sourceData.inputValueDataByValueName, sourceData.isInaccessible, sourceData.name),
|
|
685
|
+
isInaccessible: sourceData.isInaccessible,
|
|
686
|
+
kind: sourceData.kind,
|
|
687
|
+
node: {
|
|
688
|
+
kind: sourceData.kind,
|
|
689
|
+
name: (0, utils_1.stringToNameNode)(sourceData.name),
|
|
690
|
+
},
|
|
691
|
+
subgraphNames: new Set(sourceData.subgraphNames),
|
|
692
|
+
};
|
|
693
|
+
}
|
|
694
|
+
case graphql_1.Kind.INTERFACE_TYPE_DEFINITION: {
|
|
695
|
+
return {
|
|
696
|
+
...data,
|
|
697
|
+
fieldDataByFieldName: this.copyFieldDataByFieldName(sourceData.fieldDataByFieldName, sourceData.isInaccessible),
|
|
698
|
+
implementedInterfaceTypeNames: new Set(sourceData.implementedInterfaceTypeNames),
|
|
699
|
+
isEntity: sourceData.isEntity,
|
|
700
|
+
isInaccessible: sourceData.isInaccessible,
|
|
701
|
+
kind: sourceData.kind,
|
|
702
|
+
node: {
|
|
703
|
+
kind: sourceData.kind,
|
|
704
|
+
name: (0, utils_1.stringToNameNode)(sourceData.name),
|
|
705
|
+
},
|
|
706
|
+
subgraphNames: new Set(sourceData.subgraphNames),
|
|
707
|
+
};
|
|
708
|
+
}
|
|
709
|
+
case graphql_1.Kind.OBJECT_TYPE_DEFINITION: {
|
|
710
|
+
return {
|
|
711
|
+
...data,
|
|
712
|
+
fieldDataByFieldName: this.copyFieldDataByFieldName(sourceData.fieldDataByFieldName, sourceData.isInaccessible),
|
|
713
|
+
implementedInterfaceTypeNames: new Set(sourceData.implementedInterfaceTypeNames),
|
|
714
|
+
isEntity: sourceData.isEntity,
|
|
715
|
+
isInaccessible: sourceData.isInaccessible,
|
|
716
|
+
isRootType: sourceData.isRootType,
|
|
717
|
+
kind: sourceData.kind,
|
|
718
|
+
node: {
|
|
719
|
+
kind: sourceData.kind,
|
|
720
|
+
name: (0, utils_1.stringToNameNode)(sourceData.renamedTypeName || sourceData.name),
|
|
721
|
+
},
|
|
722
|
+
renamedTypeName: sourceData.renamedTypeName,
|
|
723
|
+
subgraphNames: new Set(sourceData.subgraphNames),
|
|
724
|
+
};
|
|
725
|
+
}
|
|
726
|
+
case graphql_1.Kind.SCALAR_TYPE_DEFINITION: {
|
|
727
|
+
return {
|
|
728
|
+
...data,
|
|
729
|
+
kind: sourceData.kind,
|
|
730
|
+
node: {
|
|
731
|
+
kind: sourceData.kind,
|
|
732
|
+
name: (0, utils_1.stringToNameNode)(sourceData.name),
|
|
733
|
+
},
|
|
734
|
+
};
|
|
735
|
+
}
|
|
736
|
+
case graphql_1.Kind.UNION_TYPE_DEFINITION: {
|
|
737
|
+
return {
|
|
738
|
+
...data,
|
|
739
|
+
kind: sourceData.kind,
|
|
740
|
+
node: {
|
|
741
|
+
kind: sourceData.kind,
|
|
742
|
+
name: (0, utils_1.stringToNameNode)(sourceData.name),
|
|
743
|
+
},
|
|
744
|
+
memberByMemberTypeName: new Map(sourceData.memberByMemberTypeName),
|
|
745
|
+
};
|
|
746
|
+
}
|
|
747
|
+
}
|
|
748
|
+
}
|
|
749
|
+
getParentTargetData({ existingData, incomingData, }) {
|
|
750
|
+
if (!existingData) {
|
|
751
|
+
const targetData = this.copyParentDefinitionData(incomingData);
|
|
752
|
+
if ((0, utils_5.isParentDataRootType)(targetData)) {
|
|
753
|
+
targetData.extensionType = types_1.ExtensionType.NONE;
|
|
580
754
|
}
|
|
755
|
+
return targetData;
|
|
581
756
|
}
|
|
757
|
+
(0, utils_5.extractPersistedDirectives)(existingData.persistedDirectivesData, incomingData.directivesByDirectiveName, this.persistedDirectiveDefinitionByDirectiveName);
|
|
758
|
+
return existingData;
|
|
582
759
|
}
|
|
583
760
|
upsertParentDefinitionData(incomingData, subgraphName) {
|
|
584
761
|
const entityInterfaceData = this.entityInterfaceFederationDataByTypeName.get(incomingData.name);
|
|
585
762
|
const existingData = this.parentDefinitionDataByTypeName.get(incomingData.name);
|
|
586
|
-
const
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
const isParentInaccessible = (0, utils_5.isNodeDataInaccessible)(baseData);
|
|
763
|
+
const targetData = this.getParentTargetData({ existingData, incomingData });
|
|
764
|
+
this.recordTagNamesByCoords(targetData);
|
|
765
|
+
const isParentInaccessible = (0, utils_5.isNodeDataInaccessible)(targetData);
|
|
590
766
|
if (isParentInaccessible) {
|
|
591
|
-
this.
|
|
767
|
+
this.inaccessibleCoords.add(targetData.name);
|
|
592
768
|
}
|
|
593
769
|
if (entityInterfaceData && entityInterfaceData.interfaceObjectSubgraphs.has(subgraphName)) {
|
|
594
|
-
|
|
770
|
+
targetData.kind = graphql_1.Kind.INTERFACE_TYPE_DEFINITION;
|
|
771
|
+
targetData.node.kind = graphql_1.Kind.INTERFACE_TYPE_DEFINITION;
|
|
595
772
|
}
|
|
596
773
|
if (!existingData) {
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
kind: incomingData.kind,
|
|
600
|
-
name: (0, utils_1.stringToNameNode)(incomingData.name),
|
|
601
|
-
};
|
|
602
|
-
this.parentDefinitionDataByTypeName.set(incomingData.name, incomingData);
|
|
603
|
-
switch (incomingData.kind) {
|
|
604
|
-
case graphql_1.Kind.ENUM_TYPE_DEFINITION:
|
|
605
|
-
for (const [enumValueName, enumValueData] of incomingData.enumValueDataByValueName) {
|
|
606
|
-
const enumValuePath = `${incomingData.name}.${enumValueName}`;
|
|
607
|
-
enumValueData.description = this.getInitialNodeDescription(enumValueData);
|
|
608
|
-
enumValueData.node = {
|
|
609
|
-
directives: [],
|
|
610
|
-
kind: enumValueData.node.kind,
|
|
611
|
-
name: (0, utils_1.stringToNameNode)(enumValueData.name),
|
|
612
|
-
};
|
|
613
|
-
(0, utils_5.extractPersistedDirectives)(enumValueData.persistedDirectivesData, enumValueData.directivesByDirectiveName, this.persistedDirectiveDefinitionByDirectiveName);
|
|
614
|
-
this.recordTagNamesByPath(enumValueData, enumValuePath);
|
|
615
|
-
if ((0, utils_5.isNodeDataInaccessible)(enumValueData)) {
|
|
616
|
-
this.inaccessiblePaths.add(enumValuePath);
|
|
617
|
-
}
|
|
618
|
-
}
|
|
619
|
-
return;
|
|
620
|
-
case graphql_1.Kind.INPUT_OBJECT_TYPE_DEFINITION:
|
|
621
|
-
for (const [inputFieldName, inputValueData] of incomingData.inputValueDataByValueName) {
|
|
622
|
-
inputValueData.description = this.getInitialNodeDescription(inputValueData);
|
|
623
|
-
inputValueData.node = {
|
|
624
|
-
directives: [],
|
|
625
|
-
kind: inputValueData.node.kind,
|
|
626
|
-
name: (0, utils_1.stringToNameNode)(inputValueData.name),
|
|
627
|
-
type: inputValueData.type,
|
|
628
|
-
};
|
|
629
|
-
const namedInputFieldTypeName = (0, ast_1.getTypeNodeNamedTypeName)(inputValueData.type);
|
|
630
|
-
(0, utils_6.getValueOrDefault)(this.pathsByNamedTypeName, namedInputFieldTypeName, () => new Set()).add(inputValueData.renamedPath);
|
|
631
|
-
this.namedInputValueTypeNames.add(namedInputFieldTypeName);
|
|
632
|
-
(0, utils_5.extractPersistedDirectives)(inputValueData.persistedDirectivesData, inputValueData.directivesByDirectiveName, this.persistedDirectiveDefinitionByDirectiveName);
|
|
633
|
-
this.recordTagNamesByPath(inputValueData, `${incomingData.name}.${inputFieldName}`);
|
|
634
|
-
if (isParentInaccessible || (0, utils_5.isNodeDataInaccessible)(inputValueData)) {
|
|
635
|
-
this.inaccessiblePaths.add(inputValueData.renamedPath);
|
|
636
|
-
}
|
|
637
|
-
}
|
|
638
|
-
return;
|
|
639
|
-
case graphql_1.Kind.INTERFACE_TYPE_DEFINITION:
|
|
640
|
-
// intentional fallthrough
|
|
641
|
-
case graphql_1.Kind.OBJECT_TYPE_DEFINITION:
|
|
642
|
-
if ((0, utils_5.isParentDataRootType)(incomingData)) {
|
|
643
|
-
incomingData.extensionType = types_1.ExtensionType.NONE;
|
|
644
|
-
}
|
|
645
|
-
for (const [fieldName, fieldData] of incomingData.fieldDataByFieldName) {
|
|
646
|
-
fieldData.description = this.getInitialNodeDescription(fieldData);
|
|
647
|
-
fieldData.node = {
|
|
648
|
-
arguments: [],
|
|
649
|
-
directives: [],
|
|
650
|
-
kind: fieldData.node.kind,
|
|
651
|
-
name: (0, utils_1.stringToNameNode)(fieldData.name),
|
|
652
|
-
type: fieldData.type,
|
|
653
|
-
};
|
|
654
|
-
const fieldPath = `${fieldData.renamedParentTypeName}.${fieldName}`;
|
|
655
|
-
this.handleSubscriptionFilterDirective(fieldData, fieldPath);
|
|
656
|
-
(0, utils_6.getValueOrDefault)(this.pathsByNamedTypeName, fieldData.namedTypeName, () => new Set()).add(fieldPath);
|
|
657
|
-
this.namedOutputTypeNames.add(fieldData.namedTypeName);
|
|
658
|
-
(0, utils_5.extractPersistedDirectives)(fieldData.persistedDirectivesData, fieldData.directivesByDirectiveName, this.persistedDirectiveDefinitionByDirectiveName);
|
|
659
|
-
this.recordTagNamesByPath(fieldData, fieldPath);
|
|
660
|
-
const isFieldInaccessible = (0, utils_5.isNodeDataInaccessible)(fieldData);
|
|
661
|
-
if (isParentInaccessible || isFieldInaccessible) {
|
|
662
|
-
this.inaccessiblePaths.add(fieldPath);
|
|
663
|
-
}
|
|
664
|
-
for (const [argumentName, inputValueData] of fieldData.argumentDataByArgumentName) {
|
|
665
|
-
inputValueData.description = this.getInitialNodeDescription(inputValueData);
|
|
666
|
-
inputValueData.node = {
|
|
667
|
-
directives: [],
|
|
668
|
-
kind: inputValueData.node.kind,
|
|
669
|
-
name: (0, utils_1.stringToNameNode)(inputValueData.name),
|
|
670
|
-
type: inputValueData.type,
|
|
671
|
-
};
|
|
672
|
-
const namedArgumentTypeName = (0, ast_1.getTypeNodeNamedTypeName)(inputValueData.type);
|
|
673
|
-
(0, utils_6.getValueOrDefault)(this.pathsByNamedTypeName, namedArgumentTypeName, () => new Set()).add(inputValueData.renamedPath);
|
|
674
|
-
this.namedInputValueTypeNames.add(namedArgumentTypeName);
|
|
675
|
-
(0, utils_5.extractPersistedDirectives)(inputValueData.persistedDirectivesData, inputValueData.directivesByDirectiveName, this.persistedDirectiveDefinitionByDirectiveName);
|
|
676
|
-
this.recordTagNamesByPath(inputValueData, `${fieldPath}.${argumentName}`);
|
|
677
|
-
/* If either the parent or the field to which the field belongs are declared inaccessible, the nullability
|
|
678
|
-
** of the argument is not considered. However, if only the argument is declared inaccessible, it is an
|
|
679
|
-
** error. */
|
|
680
|
-
this.handleArgumentInaccessibility(isParentInaccessible || isFieldInaccessible, inputValueData, inputValueData.renamedPath, fieldPath);
|
|
681
|
-
}
|
|
682
|
-
}
|
|
683
|
-
return;
|
|
684
|
-
default:
|
|
685
|
-
// Scalar and Union
|
|
686
|
-
return;
|
|
687
|
-
}
|
|
774
|
+
this.parentDefinitionDataByTypeName.set(targetData.name, targetData);
|
|
775
|
+
return;
|
|
688
776
|
}
|
|
689
|
-
if (
|
|
777
|
+
if (targetData.kind !== incomingData.kind) {
|
|
690
778
|
if (!entityInterfaceData ||
|
|
691
779
|
!entityInterfaceData.interfaceObjectSubgraphs.has(subgraphName) ||
|
|
692
|
-
|
|
780
|
+
targetData.kind !== graphql_1.Kind.INTERFACE_TYPE_DEFINITION ||
|
|
693
781
|
incomingData.kind !== graphql_1.Kind.OBJECT_TYPE_DEFINITION) {
|
|
694
|
-
this.errors.push((0, errors_1.incompatibleParentKindMergeError)(
|
|
782
|
+
this.errors.push((0, errors_1.incompatibleParentKindMergeError)(targetData.name, (0, utils_6.kindToTypeString)(targetData.kind), (0, utils_6.kindToTypeString)(incomingData.kind)));
|
|
695
783
|
return;
|
|
696
784
|
}
|
|
697
785
|
}
|
|
698
|
-
(0,
|
|
699
|
-
|
|
700
|
-
(0,
|
|
701
|
-
|
|
786
|
+
(0, utils_5.extractPersistedDirectives)(targetData.persistedDirectivesData, incomingData.directivesByDirectiveName, this.persistedDirectiveDefinitionByDirectiveName);
|
|
787
|
+
this.recordTagNamesByCoords(targetData);
|
|
788
|
+
(0, utils_6.addNewObjectValueMapEntries)(incomingData.configureDescriptionDataBySubgraphName, targetData.configureDescriptionDataBySubgraphName);
|
|
789
|
+
(0, utils_5.setLongestDescription)(targetData, incomingData);
|
|
790
|
+
(0, utils_5.setParentDataExtensionType)(targetData, incomingData);
|
|
791
|
+
switch (targetData.kind) {
|
|
702
792
|
case graphql_1.Kind.ENUM_TYPE_DEFINITION:
|
|
703
|
-
|
|
704
|
-
|
|
793
|
+
if (!(0, utils_5.areKindsEqual)(targetData, incomingData)) {
|
|
794
|
+
return;
|
|
795
|
+
}
|
|
796
|
+
targetData.appearances += 1;
|
|
797
|
+
targetData.isInaccessible ||= isParentInaccessible;
|
|
798
|
+
(0, utils_6.addIterableValuesToSet)(incomingData.subgraphNames, targetData.subgraphNames);
|
|
705
799
|
for (const data of incomingData.enumValueDataByValueName.values()) {
|
|
706
|
-
this.upsertEnumValueData(
|
|
800
|
+
this.upsertEnumValueData(targetData.enumValueDataByValueName, data, isParentInaccessible);
|
|
707
801
|
}
|
|
708
802
|
return;
|
|
709
803
|
case graphql_1.Kind.INPUT_OBJECT_TYPE_DEFINITION:
|
|
710
|
-
if (
|
|
711
|
-
|
|
804
|
+
if (!(0, utils_5.areKindsEqual)(targetData, incomingData)) {
|
|
805
|
+
return;
|
|
712
806
|
}
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
.
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
this.upsertInputValueData(
|
|
721
|
-
this.recordTagNamesByPath(inputValueData, inputFieldPath);
|
|
722
|
-
if (isParentInaccessible || (0, utils_5.isNodeDataInaccessible)(inputValueData)) {
|
|
723
|
-
this.inaccessiblePaths.add(inputFieldPath);
|
|
724
|
-
}
|
|
807
|
+
// targetData.isInaccessible currently yields the previous state not the new one.
|
|
808
|
+
if (isParentInaccessible && !targetData.isInaccessible) {
|
|
809
|
+
this.propagateInaccessibilityToExistingChildren(targetData);
|
|
810
|
+
}
|
|
811
|
+
targetData.isInaccessible ||= isParentInaccessible;
|
|
812
|
+
(0, utils_6.addIterableValuesToSet)(incomingData.subgraphNames, targetData.subgraphNames);
|
|
813
|
+
for (const inputValueData of incomingData.inputValueDataByValueName.values()) {
|
|
814
|
+
this.upsertInputValueData(targetData.inputValueDataByValueName, inputValueData, targetData.name, targetData.isInaccessible);
|
|
725
815
|
}
|
|
726
816
|
return;
|
|
727
817
|
case graphql_1.Kind.INTERFACE_TYPE_DEFINITION:
|
|
728
818
|
// intentional fallthrough
|
|
729
819
|
case graphql_1.Kind.OBJECT_TYPE_DEFINITION:
|
|
730
|
-
|
|
731
|
-
this.propagateInaccessibilityToExistingChildren(existingData);
|
|
732
|
-
}
|
|
820
|
+
// Not a type guard due to entity interfaces
|
|
733
821
|
const compositeOutputData = incomingData;
|
|
734
|
-
|
|
735
|
-
(
|
|
822
|
+
// targetData.isInaccessible is not yet updated with the newest state
|
|
823
|
+
if (isParentInaccessible && !targetData.isInaccessible) {
|
|
824
|
+
this.propagateInaccessibilityToExistingChildren(targetData);
|
|
825
|
+
}
|
|
826
|
+
targetData.isInaccessible ||= isParentInaccessible;
|
|
827
|
+
(0, utils_6.addIterableValuesToSet)(compositeOutputData.implementedInterfaceTypeNames, targetData.implementedInterfaceTypeNames);
|
|
828
|
+
(0, utils_6.addIterableValuesToSet)(compositeOutputData.subgraphNames, targetData.subgraphNames);
|
|
736
829
|
for (const fieldData of compositeOutputData.fieldDataByFieldName.values()) {
|
|
737
|
-
this.upsertFieldData(
|
|
830
|
+
this.upsertFieldData(targetData.fieldDataByFieldName, fieldData, targetData.isInaccessible);
|
|
738
831
|
}
|
|
739
832
|
return;
|
|
740
833
|
case graphql_1.Kind.UNION_TYPE_DEFINITION:
|
|
741
|
-
(0,
|
|
834
|
+
if (!(0, utils_5.areKindsEqual)(targetData, incomingData)) {
|
|
835
|
+
return;
|
|
836
|
+
}
|
|
837
|
+
(0, utils_6.addMapEntries)(incomingData.memberByMemberTypeName, targetData.memberByMemberTypeName);
|
|
742
838
|
return;
|
|
743
839
|
default:
|
|
744
|
-
// Scalar
|
|
840
|
+
// Scalar
|
|
745
841
|
return;
|
|
746
842
|
}
|
|
747
843
|
}
|
|
748
844
|
propagateInaccessibilityToExistingChildren(data) {
|
|
749
|
-
data.isInaccessible = true;
|
|
750
845
|
switch (data.kind) {
|
|
751
846
|
case graphql_1.Kind.INPUT_OBJECT_TYPE_DEFINITION:
|
|
752
|
-
for (const
|
|
753
|
-
this.
|
|
847
|
+
for (const inputFieldData of data.inputValueDataByValueName.values()) {
|
|
848
|
+
this.inaccessibleCoords.add(inputFieldData.federatedCoords);
|
|
754
849
|
}
|
|
755
850
|
break;
|
|
756
851
|
default:
|
|
757
|
-
for (const
|
|
758
|
-
|
|
759
|
-
this.inaccessiblePaths.add(fieldPath);
|
|
852
|
+
for (const fieldData of data.fieldDataByFieldName.values()) {
|
|
853
|
+
this.inaccessibleCoords.add(fieldData.federatedCoords);
|
|
760
854
|
for (const inputValueData of fieldData.argumentDataByArgumentName.values()) {
|
|
761
|
-
this.
|
|
855
|
+
this.inaccessibleCoords.add(inputValueData.federatedCoords);
|
|
762
856
|
}
|
|
763
857
|
}
|
|
764
858
|
}
|
|
@@ -773,8 +867,8 @@ class FederationFactory {
|
|
|
773
867
|
}
|
|
774
868
|
const argumentDataByArgumentName = new Map();
|
|
775
869
|
for (const inputValueData of incomingData.argumentDataByArgumentName.values()) {
|
|
776
|
-
this.namedInputValueTypeNames.add(
|
|
777
|
-
this.upsertInputValueData(argumentDataByArgumentName, inputValueData);
|
|
870
|
+
this.namedInputValueTypeNames.add(inputValueData.namedTypeName);
|
|
871
|
+
this.upsertInputValueData(argumentDataByArgumentName, inputValueData, `@${incomingData.name}`, false);
|
|
778
872
|
}
|
|
779
873
|
this.potentialPersistedDirectiveDefinitionDataByDirectiveName.set(name, {
|
|
780
874
|
argumentDataByArgumentName,
|
|
@@ -799,7 +893,7 @@ class FederationFactory {
|
|
|
799
893
|
}
|
|
800
894
|
for (const inputValueData of incomingData.argumentDataByArgumentName.values()) {
|
|
801
895
|
this.namedInputValueTypeNames.add((0, ast_1.getTypeNodeNamedTypeName)(inputValueData.type));
|
|
802
|
-
this.upsertInputValueData(existingData.argumentDataByArgumentName, inputValueData);
|
|
896
|
+
this.upsertInputValueData(existingData.argumentDataByArgumentName, inputValueData, `@${existingData.name}`, false);
|
|
803
897
|
}
|
|
804
898
|
(0, utils_5.setLongestDescription)(existingData, incomingData);
|
|
805
899
|
existingData.repeatable &&= incomingData.repeatable;
|
|
@@ -831,8 +925,7 @@ class FederationFactory {
|
|
|
831
925
|
}
|
|
832
926
|
}
|
|
833
927
|
handleDisparateFieldNamedTypes() {
|
|
834
|
-
for (const [fieldCoordinates, subgraphNamesByNamedTypeName] of this
|
|
835
|
-
.subgraphNamesByNamedTypeNameByFieldCoordinates) {
|
|
928
|
+
for (const [fieldCoordinates, subgraphNamesByNamedTypeName] of this.subgraphNamesByNamedTypeNameByFieldCoords) {
|
|
836
929
|
const coordinates = fieldCoordinates.split(string_constants_2.PERIOD);
|
|
837
930
|
if (coordinates.length !== 2) {
|
|
838
931
|
continue;
|
|
@@ -1103,25 +1196,13 @@ class FederationFactory {
|
|
|
1103
1196
|
return persistedDirectiveNodes;
|
|
1104
1197
|
}
|
|
1105
1198
|
getRouterPersistedDirectiveNodes(nodeData) {
|
|
1106
|
-
const persistedDirectiveNodes = [...nodeData.persistedDirectivesData.
|
|
1199
|
+
const persistedDirectiveNodes = [...nodeData.persistedDirectivesData.tagDirectiveByName.values()];
|
|
1107
1200
|
if (nodeData.persistedDirectivesData.isDeprecated) {
|
|
1108
1201
|
persistedDirectiveNodes.push((0, utils_5.generateDeprecatedDirective)(nodeData.persistedDirectivesData.deprecatedReason));
|
|
1109
1202
|
}
|
|
1110
|
-
persistedDirectiveNodes.push(...this.getValidFlattenedPersistedDirectiveNodeArray(nodeData.persistedDirectivesData.
|
|
1203
|
+
persistedDirectiveNodes.push(...this.getValidFlattenedPersistedDirectiveNodeArray(nodeData.persistedDirectivesData.directivesByDirectiveName, nodeData.name));
|
|
1111
1204
|
return persistedDirectiveNodes;
|
|
1112
1205
|
}
|
|
1113
|
-
getInitialNodeDescription(data) {
|
|
1114
|
-
if (data.configureDescriptionDataBySubgraphName.size < 1) {
|
|
1115
|
-
return data.description;
|
|
1116
|
-
}
|
|
1117
|
-
// Does not loop because the intention is check whether to propagate the first node data description
|
|
1118
|
-
for (const { propagate, description } of data.configureDescriptionDataBySubgraphName.values()) {
|
|
1119
|
-
if (!propagate) {
|
|
1120
|
-
return;
|
|
1121
|
-
}
|
|
1122
|
-
return (0, utils_2.getDescriptionFromString)(description) || data.description;
|
|
1123
|
-
}
|
|
1124
|
-
}
|
|
1125
1206
|
getFederatedGraphNodeDescription(data) {
|
|
1126
1207
|
if (data.configureDescriptionDataBySubgraphName.size < 1) {
|
|
1127
1208
|
return data.description;
|
|
@@ -1183,7 +1264,7 @@ class FederationFactory {
|
|
|
1183
1264
|
}
|
|
1184
1265
|
else if (argumentNames.length > 0) {
|
|
1185
1266
|
// fieldConfiguration might already exist through subscriptionFilter
|
|
1186
|
-
(0, utils_6.getValueOrDefault)(this.
|
|
1267
|
+
(0, utils_6.getValueOrDefault)(this.fieldConfigurationByFieldCoords, fieldPath, () => ({
|
|
1187
1268
|
argumentNames,
|
|
1188
1269
|
fieldName: fieldData.name,
|
|
1189
1270
|
typeName: fieldData.renamedParentTypeName,
|
|
@@ -1417,7 +1498,7 @@ class FederationFactory {
|
|
|
1417
1498
|
}
|
|
1418
1499
|
const clientInterfaces = [];
|
|
1419
1500
|
for (const interfaceTypeName of data.implementedInterfaceTypeNames) {
|
|
1420
|
-
if (!this.
|
|
1501
|
+
if (!this.inaccessibleCoords.has(interfaceTypeName)) {
|
|
1421
1502
|
clientInterfaces.push((0, utils_1.stringToNamedTypeNode)(interfaceTypeName));
|
|
1422
1503
|
}
|
|
1423
1504
|
}
|
|
@@ -1459,7 +1540,7 @@ class FederationFactory {
|
|
|
1459
1540
|
const segments = coordinates.split(string_constants_2.PERIOD);
|
|
1460
1541
|
let segment = segments[0];
|
|
1461
1542
|
for (let i = 0; i < segments.length; i++) {
|
|
1462
|
-
if (this.
|
|
1543
|
+
if (this.inaccessibleCoords.has(segment)) {
|
|
1463
1544
|
return true;
|
|
1464
1545
|
}
|
|
1465
1546
|
segment += `.${segments[i + 1]}`;
|
|
@@ -1467,21 +1548,21 @@ class FederationFactory {
|
|
|
1467
1548
|
return false;
|
|
1468
1549
|
}
|
|
1469
1550
|
validateReferencesOfInaccessibleType(data) {
|
|
1470
|
-
const
|
|
1471
|
-
if (!
|
|
1551
|
+
const allCoords = this.coordsByNamedTypeName.get(data.name);
|
|
1552
|
+
if (!allCoords || allCoords.size < 1) {
|
|
1472
1553
|
return;
|
|
1473
1554
|
}
|
|
1474
|
-
const
|
|
1475
|
-
for (const
|
|
1476
|
-
if (this.
|
|
1555
|
+
const invalidCoords = [];
|
|
1556
|
+
for (const coords of allCoords) {
|
|
1557
|
+
if (this.inaccessibleCoords.has(coords)) {
|
|
1477
1558
|
continue;
|
|
1478
1559
|
}
|
|
1479
|
-
if (!this.validatePathSegmentInaccessibility(
|
|
1480
|
-
|
|
1560
|
+
if (!this.validatePathSegmentInaccessibility(coords)) {
|
|
1561
|
+
invalidCoords.push(coords);
|
|
1481
1562
|
}
|
|
1482
1563
|
}
|
|
1483
|
-
if (
|
|
1484
|
-
this.errors.push((0, errors_1.invalidReferencesOfInaccessibleTypeError)((0, utils_6.kindToTypeString)(data.kind), data.name,
|
|
1564
|
+
if (invalidCoords.length > 0) {
|
|
1565
|
+
this.errors.push((0, errors_1.invalidReferencesOfInaccessibleTypeError)((0, utils_6.kindToTypeString)(data.kind), data.name, invalidCoords));
|
|
1485
1566
|
}
|
|
1486
1567
|
}
|
|
1487
1568
|
validateQueryRootType() {
|
|
@@ -1504,7 +1585,7 @@ class FederationFactory {
|
|
|
1504
1585
|
return [];
|
|
1505
1586
|
}
|
|
1506
1587
|
let lastData = objectData;
|
|
1507
|
-
if (this.
|
|
1588
|
+
if (this.inaccessibleCoords.has(lastData.renamedTypeName)) {
|
|
1508
1589
|
fieldErrorMessages.push((0, errors_1.inaccessibleSubscriptionFieldConditionFieldPathFieldErrorMessage)(inputFieldPath, conditionFieldPath, paths[0], lastData.renamedTypeName));
|
|
1509
1590
|
return [];
|
|
1510
1591
|
}
|
|
@@ -1526,7 +1607,7 @@ class FederationFactory {
|
|
|
1526
1607
|
fieldErrorMessages.push((0, errors_1.invalidSubscriptionFieldConditionFieldPathFieldErrorMessage)(inputFieldPath, conditionFieldPath, partialConditionFieldPath, fieldPath, directiveSubgraphName));
|
|
1527
1608
|
return [];
|
|
1528
1609
|
}
|
|
1529
|
-
if (this.
|
|
1610
|
+
if (this.inaccessibleCoords.has(fieldPath)) {
|
|
1530
1611
|
fieldErrorMessages.push((0, errors_1.inaccessibleSubscriptionFieldConditionFieldPathFieldErrorMessage)(inputFieldPath, conditionFieldPath, partialConditionFieldPath, fieldPath));
|
|
1531
1612
|
return [];
|
|
1532
1613
|
}
|
|
@@ -1738,7 +1819,7 @@ class FederationFactory {
|
|
|
1738
1819
|
this.isMaxDepth = false;
|
|
1739
1820
|
return;
|
|
1740
1821
|
}
|
|
1741
|
-
(0, utils_6.getValueOrDefault)(this.
|
|
1822
|
+
(0, utils_6.getValueOrDefault)(this.fieldConfigurationByFieldCoords, fieldPath, () => ({
|
|
1742
1823
|
argumentNames: [],
|
|
1743
1824
|
fieldName,
|
|
1744
1825
|
typeName: parentTypeName,
|
|
@@ -1746,7 +1827,7 @@ class FederationFactory {
|
|
|
1746
1827
|
}
|
|
1747
1828
|
validateSubscriptionFiltersAndGenerateConfiguration() {
|
|
1748
1829
|
for (const [fieldPath, data] of this.subscriptionFilterDataByFieldPath) {
|
|
1749
|
-
if (this.
|
|
1830
|
+
if (this.inaccessibleCoords.has(fieldPath)) {
|
|
1750
1831
|
continue;
|
|
1751
1832
|
}
|
|
1752
1833
|
const namedTypeData = this.parentDefinitionDataByTypeName.get(data.fieldData.namedTypeName);
|
|
@@ -1784,6 +1865,13 @@ class FederationFactory {
|
|
|
1784
1865
|
this.pushParentDefinitionDataToDocumentDefinitions(definitionsWithInterfaces);
|
|
1785
1866
|
this.validateInterfaceImplementationsAndPushToDocumentDefinitions(definitionsWithInterfaces);
|
|
1786
1867
|
this.validateQueryRootType();
|
|
1868
|
+
/*
|
|
1869
|
+
* If an input value (field or argument) is declared @inaccessible but its parent is not, it is an error.
|
|
1870
|
+
* However, this state can only be known after all subgraphs have been federated.
|
|
1871
|
+
*/
|
|
1872
|
+
for (const err of this.inaccessibleRequiredInputValueErrorByCoords.values()) {
|
|
1873
|
+
this.errors.push(err);
|
|
1874
|
+
}
|
|
1787
1875
|
// Return any composition errors before checking whether all fields are resolvable
|
|
1788
1876
|
if (this.errors.length > 0) {
|
|
1789
1877
|
return { errors: this.errors, success: false, warnings: this.warnings };
|
|
@@ -1813,14 +1901,15 @@ class FederationFactory {
|
|
|
1813
1901
|
for (const subgraph of this.internalSubgraphBySubgraphName.values()) {
|
|
1814
1902
|
subgraphConfigBySubgraphName.set(subgraph.name, {
|
|
1815
1903
|
configurationDataByTypeName: subgraph.configurationDataByTypeName,
|
|
1904
|
+
parentDefinitionDataByTypeName: subgraph.parentDefinitionDataByTypeName,
|
|
1816
1905
|
schema: subgraph.schema,
|
|
1817
1906
|
});
|
|
1818
1907
|
}
|
|
1819
1908
|
for (const authorizationData of this.authorizationDataByParentTypeName.values()) {
|
|
1820
|
-
(0, utils_3.upsertAuthorizationConfiguration)(this.
|
|
1909
|
+
(0, utils_3.upsertAuthorizationConfiguration)(this.fieldConfigurationByFieldCoords, authorizationData);
|
|
1821
1910
|
}
|
|
1822
1911
|
return {
|
|
1823
|
-
fieldConfigurations: Array.from(this.
|
|
1912
|
+
fieldConfigurations: Array.from(this.fieldConfigurationByFieldCoords.values()),
|
|
1824
1913
|
subgraphConfigBySubgraphName,
|
|
1825
1914
|
federatedGraphAST: newRouterAST,
|
|
1826
1915
|
federatedGraphSchema: (0, graphql_1.buildASTSchema)(newRouterAST, { assumeValid: true, assumeValidSDL: true }),
|
|
@@ -1833,7 +1922,7 @@ class FederationFactory {
|
|
|
1833
1922
|
}
|
|
1834
1923
|
getClientSchemaObjectBoolean() {
|
|
1835
1924
|
// If the schema does not implement @tag nor @inaccessible, an empty object will be spread
|
|
1836
|
-
if (this.
|
|
1925
|
+
if (this.inaccessibleCoords.size < 1 && this.tagNamesByCoords.size < 1) {
|
|
1837
1926
|
return {};
|
|
1838
1927
|
}
|
|
1839
1928
|
// otherwise, the object is spread in as true
|
|
@@ -1848,18 +1937,18 @@ class FederationFactory {
|
|
|
1848
1937
|
continue;
|
|
1849
1938
|
}
|
|
1850
1939
|
if (!tagNames.isDisjointFrom(childTagData.tagNames)) {
|
|
1851
|
-
(0, utils_6.getValueOrDefault)(childData.persistedDirectivesData.
|
|
1940
|
+
(0, utils_6.getValueOrDefault)(childData.persistedDirectivesData.directivesByDirectiveName, string_constants_2.INACCESSIBLE, () => [
|
|
1852
1941
|
(0, utils_6.generateSimpleDirective)(string_constants_2.INACCESSIBLE),
|
|
1853
1942
|
]);
|
|
1854
|
-
this.
|
|
1943
|
+
this.inaccessibleCoords.add(`${parentDefinitionData.name}.${childName}`);
|
|
1855
1944
|
accessibleChildren -= 1;
|
|
1856
1945
|
}
|
|
1857
1946
|
}
|
|
1858
1947
|
if (accessibleChildren < 1) {
|
|
1859
|
-
parentDefinitionData.persistedDirectivesData.
|
|
1948
|
+
parentDefinitionData.persistedDirectivesData.directivesByDirectiveName.set(string_constants_2.INACCESSIBLE, [
|
|
1860
1949
|
(0, utils_6.generateSimpleDirective)(string_constants_2.INACCESSIBLE),
|
|
1861
1950
|
]);
|
|
1862
|
-
this.
|
|
1951
|
+
this.inaccessibleCoords.add(parentDefinitionData.name);
|
|
1863
1952
|
}
|
|
1864
1953
|
}
|
|
1865
1954
|
handleChildTagInclusions(parentDefinitionData, children, childTagDataByChildName, tagNames) {
|
|
@@ -1871,18 +1960,18 @@ class FederationFactory {
|
|
|
1871
1960
|
}
|
|
1872
1961
|
const childTagData = childTagDataByChildName.get(childName);
|
|
1873
1962
|
if (!childTagData || tagNames.isDisjointFrom(childTagData.tagNames)) {
|
|
1874
|
-
(0, utils_6.getValueOrDefault)(childData.persistedDirectivesData.
|
|
1963
|
+
(0, utils_6.getValueOrDefault)(childData.persistedDirectivesData.directivesByDirectiveName, string_constants_2.INACCESSIBLE, () => [
|
|
1875
1964
|
(0, utils_6.generateSimpleDirective)(string_constants_2.INACCESSIBLE),
|
|
1876
1965
|
]);
|
|
1877
|
-
this.
|
|
1966
|
+
this.inaccessibleCoords.add(`${parentDefinitionData.name}.${childName}`);
|
|
1878
1967
|
accessibleChildren -= 1;
|
|
1879
1968
|
}
|
|
1880
1969
|
}
|
|
1881
1970
|
if (accessibleChildren < 1) {
|
|
1882
|
-
parentDefinitionData.persistedDirectivesData.
|
|
1971
|
+
parentDefinitionData.persistedDirectivesData.directivesByDirectiveName.set(string_constants_2.INACCESSIBLE, [
|
|
1883
1972
|
(0, utils_6.generateSimpleDirective)(string_constants_2.INACCESSIBLE),
|
|
1884
1973
|
]);
|
|
1885
|
-
this.
|
|
1974
|
+
this.inaccessibleCoords.add(parentDefinitionData.name);
|
|
1886
1975
|
}
|
|
1887
1976
|
}
|
|
1888
1977
|
buildFederationContractResult(contractTagOptions) {
|
|
@@ -1898,10 +1987,10 @@ class FederationFactory {
|
|
|
1898
1987
|
continue;
|
|
1899
1988
|
}
|
|
1900
1989
|
if (!contractTagOptions.tagNamesToExclude.isDisjointFrom(parentTagData.tagNames)) {
|
|
1901
|
-
parentDefinitionData.persistedDirectivesData.
|
|
1990
|
+
parentDefinitionData.persistedDirectivesData.directivesByDirectiveName.set(string_constants_2.INACCESSIBLE, [
|
|
1902
1991
|
(0, utils_6.generateSimpleDirective)(string_constants_2.INACCESSIBLE),
|
|
1903
1992
|
]);
|
|
1904
|
-
this.
|
|
1993
|
+
this.inaccessibleCoords.add(parentTypeName);
|
|
1905
1994
|
// If the parent is inaccessible, there is no need to assess further
|
|
1906
1995
|
continue;
|
|
1907
1996
|
}
|
|
@@ -1928,10 +2017,10 @@ class FederationFactory {
|
|
|
1928
2017
|
continue;
|
|
1929
2018
|
}
|
|
1930
2019
|
if (!contractTagOptions.tagNamesToExclude.isDisjointFrom(childTagData.tagNames)) {
|
|
1931
|
-
(0, utils_6.getValueOrDefault)(fieldData.persistedDirectivesData.
|
|
2020
|
+
(0, utils_6.getValueOrDefault)(fieldData.persistedDirectivesData.directivesByDirectiveName, string_constants_2.INACCESSIBLE, () => [
|
|
1932
2021
|
(0, utils_6.generateSimpleDirective)(string_constants_2.INACCESSIBLE),
|
|
1933
2022
|
]);
|
|
1934
|
-
this.
|
|
2023
|
+
this.inaccessibleCoords.add(fieldData.federatedCoords);
|
|
1935
2024
|
accessibleFields -= 1;
|
|
1936
2025
|
continue;
|
|
1937
2026
|
}
|
|
@@ -1941,18 +2030,16 @@ class FederationFactory {
|
|
|
1941
2030
|
continue;
|
|
1942
2031
|
}
|
|
1943
2032
|
if (!tagNames.isDisjointFrom(tagNames)) {
|
|
1944
|
-
(0, utils_6.getValueOrDefault)(inputValueData.persistedDirectivesData.
|
|
1945
|
-
|
|
1946
|
-
]);
|
|
1947
|
-
this.inaccessiblePaths.add(inputValueData.renamedPath);
|
|
2033
|
+
(0, utils_6.getValueOrDefault)(inputValueData.persistedDirectivesData.directivesByDirectiveName, string_constants_2.INACCESSIBLE, () => [(0, utils_6.generateSimpleDirective)(string_constants_2.INACCESSIBLE)]);
|
|
2034
|
+
this.inaccessibleCoords.add(inputValueData.federatedCoords);
|
|
1948
2035
|
}
|
|
1949
2036
|
}
|
|
1950
2037
|
}
|
|
1951
2038
|
if (accessibleFields < 1) {
|
|
1952
|
-
parentDefinitionData.persistedDirectivesData.
|
|
2039
|
+
parentDefinitionData.persistedDirectivesData.directivesByDirectiveName.set(string_constants_2.INACCESSIBLE, [
|
|
1953
2040
|
(0, utils_6.generateSimpleDirective)(string_constants_2.INACCESSIBLE),
|
|
1954
2041
|
]);
|
|
1955
|
-
this.
|
|
2042
|
+
this.inaccessibleCoords.add(parentTypeName);
|
|
1956
2043
|
}
|
|
1957
2044
|
}
|
|
1958
2045
|
}
|
|
@@ -1964,10 +2051,10 @@ class FederationFactory {
|
|
|
1964
2051
|
}
|
|
1965
2052
|
const parentTagData = this.parentTagDataByTypeName.get(parentTypeName);
|
|
1966
2053
|
if (!parentTagData) {
|
|
1967
|
-
parentDefinitionData.persistedDirectivesData.
|
|
2054
|
+
parentDefinitionData.persistedDirectivesData.directivesByDirectiveName.set(string_constants_2.INACCESSIBLE, [
|
|
1968
2055
|
(0, utils_6.generateSimpleDirective)(string_constants_2.INACCESSIBLE),
|
|
1969
2056
|
]);
|
|
1970
|
-
this.
|
|
2057
|
+
this.inaccessibleCoords.add(parentTypeName);
|
|
1971
2058
|
// If the parent is inaccessible, there is no need to assess further
|
|
1972
2059
|
continue;
|
|
1973
2060
|
}
|
|
@@ -1975,10 +2062,10 @@ class FederationFactory {
|
|
|
1975
2062
|
continue;
|
|
1976
2063
|
}
|
|
1977
2064
|
if (parentTagData.childTagDataByChildName.size < 1) {
|
|
1978
|
-
parentDefinitionData.persistedDirectivesData.
|
|
2065
|
+
parentDefinitionData.persistedDirectivesData.directivesByDirectiveName.set(string_constants_2.INACCESSIBLE, [
|
|
1979
2066
|
(0, utils_6.generateSimpleDirective)(string_constants_2.INACCESSIBLE),
|
|
1980
2067
|
]);
|
|
1981
|
-
this.
|
|
2068
|
+
this.inaccessibleCoords.add(parentTypeName);
|
|
1982
2069
|
// If the parent is inaccessible, there is no need to assess further
|
|
1983
2070
|
continue;
|
|
1984
2071
|
}
|
|
@@ -2002,18 +2089,18 @@ class FederationFactory {
|
|
|
2002
2089
|
}
|
|
2003
2090
|
const childTagData = parentTagData.childTagDataByChildName.get(fieldName);
|
|
2004
2091
|
if (!childTagData || contractTagOptions.tagNamesToInclude.isDisjointFrom(childTagData.tagNames)) {
|
|
2005
|
-
(0, utils_6.getValueOrDefault)(fieldData.persistedDirectivesData.
|
|
2092
|
+
(0, utils_6.getValueOrDefault)(fieldData.persistedDirectivesData.directivesByDirectiveName, string_constants_2.INACCESSIBLE, () => [
|
|
2006
2093
|
(0, utils_6.generateSimpleDirective)(string_constants_2.INACCESSIBLE),
|
|
2007
2094
|
]);
|
|
2008
|
-
this.
|
|
2095
|
+
this.inaccessibleCoords.add(fieldData.federatedCoords);
|
|
2009
2096
|
accessibleFields -= 1;
|
|
2010
2097
|
}
|
|
2011
2098
|
}
|
|
2012
2099
|
if (accessibleFields < 1) {
|
|
2013
|
-
parentDefinitionData.persistedDirectivesData.
|
|
2100
|
+
parentDefinitionData.persistedDirectivesData.directivesByDirectiveName.set(string_constants_2.INACCESSIBLE, [
|
|
2014
2101
|
(0, utils_6.generateSimpleDirective)(string_constants_2.INACCESSIBLE),
|
|
2015
2102
|
]);
|
|
2016
|
-
this.
|
|
2103
|
+
this.inaccessibleCoords.add(parentTypeName);
|
|
2017
2104
|
}
|
|
2018
2105
|
}
|
|
2019
2106
|
}
|
|
@@ -2043,14 +2130,15 @@ class FederationFactory {
|
|
|
2043
2130
|
for (const subgraph of this.internalSubgraphBySubgraphName.values()) {
|
|
2044
2131
|
subgraphConfigBySubgraphName.set(subgraph.name, {
|
|
2045
2132
|
configurationDataByTypeName: subgraph.configurationDataByTypeName,
|
|
2133
|
+
parentDefinitionDataByTypeName: subgraph.parentDefinitionDataByTypeName,
|
|
2046
2134
|
schema: subgraph.schema,
|
|
2047
2135
|
});
|
|
2048
2136
|
}
|
|
2049
2137
|
for (const authorizationData of this.authorizationDataByParentTypeName.values()) {
|
|
2050
|
-
(0, utils_3.upsertAuthorizationConfiguration)(this.
|
|
2138
|
+
(0, utils_3.upsertAuthorizationConfiguration)(this.fieldConfigurationByFieldCoords, authorizationData);
|
|
2051
2139
|
}
|
|
2052
2140
|
return {
|
|
2053
|
-
fieldConfigurations: Array.from(this.
|
|
2141
|
+
fieldConfigurations: Array.from(this.fieldConfigurationByFieldCoords.values()),
|
|
2054
2142
|
subgraphConfigBySubgraphName,
|
|
2055
2143
|
federatedGraphAST: newRouterAST,
|
|
2056
2144
|
federatedGraphSchema: (0, graphql_1.buildASTSchema)(newRouterAST, { assumeValid: true, assumeValidSDL: true }),
|