@wundergraph/composition 0.55.0 → 0.56.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/ast/utils.d.ts +1 -0
- package/dist/normalization/types.d.ts +9 -7
- package/dist/resolvability-graph/graph.d.ts +4 -3
- package/dist/resolvability-graph/graph.js +31 -36
- package/dist/resolvability-graph/graph.js.map +1 -1
- package/dist/resolvability-graph/types/types.d.ts +2 -1
- package/dist/resolvability-graph/utils/types/params.d.ts +8 -1
- package/dist/resolvability-graph/utils/types/types.d.ts +1 -0
- package/dist/resolvability-graph/utils/utils.js +62 -9
- package/dist/resolvability-graph/utils/utils.js.map +1 -1
- package/dist/schema-building/params.d.ts +8 -0
- package/dist/schema-building/params.js +3 -0
- package/dist/schema-building/params.js.map +1 -0
- package/dist/schema-building/utils.d.ts +6 -3
- package/dist/schema-building/utils.js +29 -8
- package/dist/schema-building/utils.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/types/types.d.ts +2 -0
- package/dist/utils/composition-version.js +1 -1
- package/dist/utils/string-constants.d.ts +1 -0
- package/dist/utils/string-constants.js +2 -1
- package/dist/utils/string-constants.js.map +1 -1
- package/dist/utils/types.d.ts +2 -2
- package/dist/v1/federation/federation-factory.d.ts +3 -2
- package/dist/v1/federation/federation-factory.js +10 -2
- package/dist/v1/federation/federation-factory.js.map +1 -1
- package/dist/v1/federation/params.d.ts +2 -1
- package/dist/v1/normalization/normalization-factory.d.ts +7 -5
- package/dist/v1/normalization/normalization-factory.js +65 -3
- package/dist/v1/normalization/normalization-factory.js.map +1 -1
- package/dist/v1/normalization/params.d.ts +7 -1
- package/package.json +2 -2
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type ConstDirectiveNode, type ConstValueNode, type DirectiveDefinitionNode, type DocumentNode, type EnumValueDefinitionNode, type FieldDefinitionNode, type InputValueDefinitionNode, type InterfaceTypeDefinitionNode,
|
|
1
|
+
import { type ConstDirectiveNode, type ConstValueNode, type DirectiveDefinitionNode, type DocumentNode, type EnumValueDefinitionNode, type FieldDefinitionNode, type InputValueDefinitionNode, type InterfaceTypeDefinitionNode, Kind, type NamedTypeNode, OperationTypeNode, type SchemaDefinitionNode, type SchemaExtensionNode, type TypeDefinitionNode, type TypeExtensionNode, type TypeNode } from 'graphql';
|
|
2
2
|
import { type EnumTypeNode, type InputObjectTypeNode, type InterfaceTypeNode, type ObjectTypeNode, type ScalarTypeNode, type SchemaNode, type UnionTypeNode } from '../../ast/utils';
|
|
3
3
|
import { type ConfigurationData, type Costs, type EventConfiguration, type NatsEventType, type RequiredFieldConfiguration } from '../../router-configuration/types';
|
|
4
4
|
import { type AuthorizationData, type CompositeOutputData, type ConditionalFieldData, type EntityData, type EntityInterfaceSubgraphData, type EnumDefinitionData, ExtensionType, type FieldData, type InputObjectDefinitionData, type InputValueData, type NodeData, type ObjectDefinitionData, type ParentDefinitionData, type PersistedDirectiveDefinitionData, type ScalarDefinitionData, type SchemaData, type UnionDefinitionData } from '../../schema-building/types';
|
|
@@ -8,8 +8,8 @@ import { Graph } from '../../resolvability-graph/graph';
|
|
|
8
8
|
import { type Warning } from '../../warnings/types';
|
|
9
9
|
import { type BatchNormalizationResult, type NormalizationResult } from '../../normalization/types';
|
|
10
10
|
import { type AddInputValueDataByNodeParams, type ConditionalFieldSetValidationResult, type ExtractArgumentDataResult, type FieldSetData, type FieldSetParentResult, type HandleCostDirectiveParams, type HandleListSizeDirectiveParams, type HandleOverrideDirectiveParams, type HandleRequiresScopesDirectiveParams, type HandleSemanticNonNullDirectiveParams, type KeyFieldSetData, type UpsertInputObjectResult, type ValidateDirectiveParams } from './types';
|
|
11
|
-
import { type SubgraphName } from '../../types/types';
|
|
12
|
-
import { type BatchNormalizeParams, type HandleFieldInheritableDirectivesParams, type NormalizationFactoryParams, type NormalizeSubgraphFromStringParams, type NormalizeSubgraphParams, type ValidateOneOfDirectiveParams } from './params';
|
|
11
|
+
import { type AbstractTypeName, type SubgraphName, type TypeName } from '../../types/types';
|
|
12
|
+
import { type BatchNormalizeParams, type HandleFieldInheritableDirectivesParams, type NormalizationFactoryParams, type NormalizeSubgraphFromStringParams, type NormalizeSubgraphParams, type SanitizeDefaultValueParams, type ValidateOneOfDirectiveParams } from './params';
|
|
13
13
|
import type { CompositionOptions } from '../../types/params';
|
|
14
14
|
export declare function normalizeSubgraphFromString({ noLocation, options, sdlString, }: NormalizeSubgraphFromStringParams): NormalizationResult;
|
|
15
15
|
export declare function normalizeSubgraph({ document, internalGraph, options, subgraphName, }: NormalizeSubgraphParams): NormalizationResult;
|
|
@@ -32,6 +32,7 @@ export declare class NormalizationFactory {
|
|
|
32
32
|
entityInterfaceDataByTypeName: Map<string, EntityInterfaceSubgraphData>;
|
|
33
33
|
eventsConfigurations: Map<string, EventConfiguration[]>;
|
|
34
34
|
fieldSetDataByTypeName: Map<string, FieldSetData>;
|
|
35
|
+
interfaceImplementationTypeNamesByInterfaceTypeName: Map<string, Set<string>>;
|
|
35
36
|
internalGraph: Graph;
|
|
36
37
|
invalidConfigureDescriptionNodeDatas: Array<NodeData>;
|
|
37
38
|
invalidORScopesCoords: Set<string>;
|
|
@@ -62,6 +63,7 @@ export declare class NormalizationFactory {
|
|
|
62
63
|
usesEdfsNatsStreamConfiguration: boolean;
|
|
63
64
|
warnings: Array<Warning>;
|
|
64
65
|
constructor({ internalGraph, options, subgraphName }: NormalizationFactoryParams);
|
|
66
|
+
sanitizeDefaultValue({ data, namedTypeData, node }: SanitizeDefaultValueParams): void;
|
|
65
67
|
validateArguments(fieldData: FieldData, parentKind: Kind): void;
|
|
66
68
|
isTypeNameRootType(typeName: string): boolean;
|
|
67
69
|
isArgumentValueValid(typeNode: TypeNode, argumentValue: ConstValueNode): boolean;
|
|
@@ -73,9 +75,9 @@ export declare class NormalizationFactory {
|
|
|
73
75
|
setParentDataExtensionType(parentData: ParentDefinitionData, incomingExtensionType: ExtensionType): void;
|
|
74
76
|
extractConfigureDescriptionData(data: NodeData, directiveNode: ConstDirectiveNode): void;
|
|
75
77
|
extractConfigureDescriptionsData(data: NodeData): void;
|
|
76
|
-
extractImplementedInterfaceTypeNames(node:
|
|
78
|
+
extractImplementedInterfaceTypeNames(node: InterfaceTypeNode | ObjectTypeNode, implementedInterfaceTypeNames: Set<AbstractTypeName>): Set<AbstractTypeName>;
|
|
77
79
|
updateCompositeOutputDataByNode(node: CompositeOutputNode, data: CompositeOutputData, extensionType: ExtensionType): void;
|
|
78
|
-
addConcreteTypeNamesForImplementedInterfaces(interfaceTypeNames: Set<
|
|
80
|
+
addConcreteTypeNamesForImplementedInterfaces(interfaceTypeNames: Set<AbstractTypeName>, concreteTypeName: TypeName): void;
|
|
79
81
|
extractArguments(argumentDataByName: Map<string, InputValueData>, node: FieldDefinitionNode): Map<string, InputValueData>;
|
|
80
82
|
addPersistedDirectiveDefinitionDataByNode(persistedDirectiveDefinitionDataByDirectiveName: Map<string, PersistedDirectiveDefinitionData>, node: DirectiveDefinitionNode, executableLocations: Set<string>): void;
|
|
81
83
|
extractDirectiveLocations(node: DirectiveDefinitionNode, errorMessages: Array<string>): Set<string>;
|
|
@@ -65,6 +65,7 @@ class NormalizationFactory {
|
|
|
65
65
|
entityInterfaceDataByTypeName = new Map();
|
|
66
66
|
eventsConfigurations = new Map();
|
|
67
67
|
fieldSetDataByTypeName = new Map();
|
|
68
|
+
interfaceImplementationTypeNamesByInterfaceTypeName = new Map();
|
|
68
69
|
internalGraph;
|
|
69
70
|
invalidConfigureDescriptionNodeDatas = [];
|
|
70
71
|
invalidORScopesCoords = new Set();
|
|
@@ -106,6 +107,27 @@ class NormalizationFactory {
|
|
|
106
107
|
operationTypes: new Map(),
|
|
107
108
|
};
|
|
108
109
|
}
|
|
110
|
+
sanitizeDefaultValue({ data, namedTypeData, node }) {
|
|
111
|
+
if (!data.defaultValue) {
|
|
112
|
+
return;
|
|
113
|
+
}
|
|
114
|
+
if (!(0, utils_4.isEnumData)(namedTypeData)) {
|
|
115
|
+
return;
|
|
116
|
+
}
|
|
117
|
+
data.defaultValue = (0, graphql_1.visit)(data.defaultValue, {
|
|
118
|
+
StringValue: {
|
|
119
|
+
enter(node) {
|
|
120
|
+
return {
|
|
121
|
+
kind: graphql_1.Kind.ENUM,
|
|
122
|
+
value: node.value,
|
|
123
|
+
};
|
|
124
|
+
},
|
|
125
|
+
},
|
|
126
|
+
});
|
|
127
|
+
if (node) {
|
|
128
|
+
node.defaultValue = data.defaultValue;
|
|
129
|
+
}
|
|
130
|
+
}
|
|
109
131
|
validateArguments(fieldData, parentKind) {
|
|
110
132
|
for (const argumentData of fieldData.argumentDataByName.values()) {
|
|
111
133
|
const namedTypeName = (0, ast_1.getTypeNodeNamedTypeName)(argumentData.type);
|
|
@@ -120,6 +142,7 @@ class NormalizationFactory {
|
|
|
120
142
|
}
|
|
121
143
|
if ((0, utils_4.isInputNodeKind)(namedTypeData.kind)) {
|
|
122
144
|
argumentData.namedTypeKind = namedTypeData.kind;
|
|
145
|
+
this.sanitizeDefaultValue({ data: argumentData, namedTypeData, node: argumentData.node });
|
|
123
146
|
continue;
|
|
124
147
|
}
|
|
125
148
|
this.errors.push((0, errors_1.invalidNamedTypeError)({
|
|
@@ -193,7 +216,7 @@ class NormalizationFactory {
|
|
|
193
216
|
return true;
|
|
194
217
|
}
|
|
195
218
|
if (parentData.kind === graphql_1.Kind.ENUM_TYPE_DEFINITION) {
|
|
196
|
-
if (argumentValue.kind !== graphql_1.Kind.ENUM) {
|
|
219
|
+
if (argumentValue.kind !== graphql_1.Kind.ENUM && argumentValue.kind !== graphql_1.Kind.STRING) {
|
|
197
220
|
return false;
|
|
198
221
|
}
|
|
199
222
|
const enumValue = parentData.enumValueDataByName.get(argumentValue.value);
|
|
@@ -405,6 +428,21 @@ class NormalizationFactory {
|
|
|
405
428
|
}
|
|
406
429
|
}
|
|
407
430
|
const requiredArgumentNames = [...definitionData.requiredArgumentNames];
|
|
431
|
+
for (const argumentNode of definitionData.node.arguments ?? []) {
|
|
432
|
+
if (!argumentNode.defaultValue) {
|
|
433
|
+
continue;
|
|
434
|
+
}
|
|
435
|
+
const argumentData = definitionData.argumentTypeNodeByName.get(argumentNode.name.value);
|
|
436
|
+
if (!argumentData) {
|
|
437
|
+
continue;
|
|
438
|
+
}
|
|
439
|
+
const namedTypeData = this.parentDefinitionDataByTypeName.get((0, ast_1.getTypeNodeNamedTypeName)(argumentData.typeNode));
|
|
440
|
+
// Undefined types are handled elsewhere
|
|
441
|
+
if (!namedTypeData) {
|
|
442
|
+
continue;
|
|
443
|
+
}
|
|
444
|
+
this.sanitizeDefaultValue({ data: argumentData, namedTypeData, node: argumentNode });
|
|
445
|
+
}
|
|
408
446
|
for (let i = 0; i < directiveNodes.length; i++) {
|
|
409
447
|
const errorMessages = this.validateDirective({
|
|
410
448
|
data,
|
|
@@ -543,6 +581,7 @@ class NormalizationFactory {
|
|
|
543
581
|
if (!node.interfaces) {
|
|
544
582
|
return implementedInterfaceTypeNames;
|
|
545
583
|
}
|
|
584
|
+
const isInterface = (0, utils_4.isInterfaceNode)(node);
|
|
546
585
|
const parentTypeName = node.name.value;
|
|
547
586
|
for (const implementedInterface of node.interfaces) {
|
|
548
587
|
const interfaceTypeName = implementedInterface.name.value;
|
|
@@ -550,6 +589,9 @@ class NormalizationFactory {
|
|
|
550
589
|
this.errors.push((0, errors_1.duplicateImplementedInterfaceError)((0, utils_3.kindToConvertedTypeString)(node.kind), parentTypeName, interfaceTypeName));
|
|
551
590
|
continue;
|
|
552
591
|
}
|
|
592
|
+
if (isInterface) {
|
|
593
|
+
(0, utils_5.getValueOrDefault)(this.interfaceImplementationTypeNamesByInterfaceTypeName, interfaceTypeName, () => new Set()).add(parentTypeName);
|
|
594
|
+
}
|
|
553
595
|
implementedInterfaceTypeNames.add(interfaceTypeName);
|
|
554
596
|
}
|
|
555
597
|
return implementedInterfaceTypeNames;
|
|
@@ -1550,7 +1592,12 @@ class NormalizationFactory {
|
|
|
1550
1592
|
unimplementedArguments: new Set(),
|
|
1551
1593
|
};
|
|
1552
1594
|
// The implemented field type must be equally or more restrictive than the original interface field type
|
|
1553
|
-
if (!(0, utils_4.isTypeValidImplementation)(
|
|
1595
|
+
if (!(0, utils_4.isTypeValidImplementation)({
|
|
1596
|
+
concreteTypeNamesByAbstractTypeName: this.concreteTypeNamesByAbstractTypeName,
|
|
1597
|
+
implementationType: fieldData.node.type,
|
|
1598
|
+
interfaceImplementationTypeNamesByInterfaceTypeName: this.interfaceImplementationTypeNamesByInterfaceTypeName,
|
|
1599
|
+
originalType: interfaceField.node.type,
|
|
1600
|
+
})) {
|
|
1554
1601
|
hasErrors = true;
|
|
1555
1602
|
hasNestedErrors = true;
|
|
1556
1603
|
invalidFieldImplementation.implementedResponseType = (0, merge_1.printTypeNode)(fieldData.node.type);
|
|
@@ -2933,9 +2980,10 @@ class NormalizationFactory {
|
|
|
2933
2980
|
}
|
|
2934
2981
|
const namedTypeData = this.parentDefinitionDataByTypeName.get(valueData.namedTypeName);
|
|
2935
2982
|
if (!namedTypeData) {
|
|
2936
|
-
//
|
|
2983
|
+
// Undefined types are handled elsewhere
|
|
2937
2984
|
continue;
|
|
2938
2985
|
}
|
|
2986
|
+
this.sanitizeDefaultValue({ data: valueData, namedTypeData, node: valueData.node });
|
|
2939
2987
|
if (!(0, utils_4.isInputNodeKind)(namedTypeData.kind)) {
|
|
2940
2988
|
this.errors.push((0, errors_1.invalidNamedTypeError)({
|
|
2941
2989
|
data: valueData,
|
|
@@ -3152,6 +3200,7 @@ class NormalizationFactory {
|
|
|
3152
3200
|
entityDataByTypeName: this.entityDataByTypeName,
|
|
3153
3201
|
entityInterfaces: this.entityInterfaceDataByTypeName,
|
|
3154
3202
|
fieldCoordsByNamedTypeName: this.fieldCoordsByNamedTypeName,
|
|
3203
|
+
interfaceImplementationTypeNamesByInterfaceTypeName: this.interfaceImplementationTypeNamesByInterfaceTypeName,
|
|
3155
3204
|
isEventDrivenGraph: this.isSubgraphEventDrivenGraph,
|
|
3156
3205
|
isVersionTwo: this.isSubgraphVersionTwo,
|
|
3157
3206
|
keyFieldNamesByParentTypeName: this.keyFieldNamesByParentTypeName,
|
|
@@ -3175,6 +3224,7 @@ function batchNormalize({ options, subgraphs }) {
|
|
|
3175
3224
|
const authorizationDataByParentTypeName = new Map();
|
|
3176
3225
|
const concreteTypeNamesByAbstractTypeName = new Map();
|
|
3177
3226
|
const entityDataByTypeName = new Map();
|
|
3227
|
+
const interfaceImplementationTypeNamesByInterfaceTypeName = new Map();
|
|
3178
3228
|
const internalSubgraphBySubgraphName = new Map();
|
|
3179
3229
|
const allOverridesByTargetSubgraphName = new Map();
|
|
3180
3230
|
const overrideSourceSubgraphNamesByFieldPath = new Map();
|
|
@@ -3238,6 +3288,17 @@ function batchNormalize({ options, subgraphs }) {
|
|
|
3238
3288
|
target: existingConcreteTypeNames,
|
|
3239
3289
|
});
|
|
3240
3290
|
}
|
|
3291
|
+
for (const [interfaceTypeName, incomingInterfaceTypeNames,] of normalizationResult.interfaceImplementationTypeNamesByInterfaceTypeName) {
|
|
3292
|
+
const existingInterfaceTypeNames = interfaceImplementationTypeNamesByInterfaceTypeName.get(interfaceTypeName);
|
|
3293
|
+
if (!existingInterfaceTypeNames) {
|
|
3294
|
+
interfaceImplementationTypeNamesByInterfaceTypeName.set(interfaceTypeName, new Set(incomingInterfaceTypeNames));
|
|
3295
|
+
continue;
|
|
3296
|
+
}
|
|
3297
|
+
(0, utils_5.addIterableToSet)({
|
|
3298
|
+
source: incomingInterfaceTypeNames,
|
|
3299
|
+
target: existingInterfaceTypeNames,
|
|
3300
|
+
});
|
|
3301
|
+
}
|
|
3241
3302
|
for (const [typeName, entityData] of normalizationResult.entityDataByTypeName) {
|
|
3242
3303
|
const keyFieldSetDataByFieldSet = entityData.keyFieldSetDatasBySubgraphName.get(subgraphName);
|
|
3243
3304
|
if (!keyFieldSetDataByFieldSet) {
|
|
@@ -3345,6 +3406,7 @@ function batchNormalize({ options, subgraphs }) {
|
|
|
3345
3406
|
concreteTypeNamesByAbstractTypeName,
|
|
3346
3407
|
entityDataByTypeName,
|
|
3347
3408
|
fieldCoordsByNamedTypeName,
|
|
3409
|
+
interfaceImplementationTypeNamesByInterfaceTypeName,
|
|
3348
3410
|
internalSubgraphBySubgraphName: internalSubgraphBySubgraphName,
|
|
3349
3411
|
internalGraph,
|
|
3350
3412
|
success: true,
|