@theguild/federation-composition 0.12.1 → 0.13.0-alpha-20241002090328-16d32e8
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/cjs/subgraph/state.js +11 -0
- package/cjs/supergraph/composition/enum-type.js +10 -0
- package/esm/subgraph/state.js +11 -0
- package/esm/supergraph/composition/enum-type.js +10 -0
- package/package.json +1 -1
- package/typings/subgraph/state.d.cts +4 -0
- package/typings/subgraph/state.d.ts +4 -0
- package/typings/subgraph/validation/validation-context.d.cts +1 -0
- package/typings/subgraph/validation/validation-context.d.ts +1 -0
- package/typings/supergraph/composition/enum-type.d.cts +5 -1
- package/typings/supergraph/composition/enum-type.d.ts +5 -1
package/cjs/subgraph/state.js
CHANGED
|
@@ -361,6 +361,11 @@ function createSubgraphStateBuilder(graph, typeDefs, version, links) {
|
|
|
361
361
|
}
|
|
362
362
|
break;
|
|
363
363
|
}
|
|
364
|
+
case graphql_1.Kind.ENUM_TYPE_DEFINITION:
|
|
365
|
+
case graphql_1.Kind.ENUM_TYPE_EXTENSION: {
|
|
366
|
+
enumTypeBuilder.setDirective(typeDef.name.value, node);
|
|
367
|
+
break;
|
|
368
|
+
}
|
|
364
369
|
default:
|
|
365
370
|
throw new Error(`Directives on "${typeDef.kind}" types are not supported yet`);
|
|
366
371
|
}
|
|
@@ -1126,6 +1131,9 @@ function enumTypeFactory(state) {
|
|
|
1126
1131
|
getOrCreateEnumType(state, typeName).referencedByOutputType = true;
|
|
1127
1132
|
getOrCreateEnumType(state, typeName).outputTypeReferences.add(schemaCoordinate);
|
|
1128
1133
|
},
|
|
1134
|
+
setDirective(typeName, directive) {
|
|
1135
|
+
getOrCreateEnumType(state, typeName).ast.directives.push(directive);
|
|
1136
|
+
},
|
|
1129
1137
|
value: {
|
|
1130
1138
|
setValue(typeName, valueName) {
|
|
1131
1139
|
getOrCreateEnumValue(state, typeName, valueName);
|
|
@@ -1317,6 +1325,9 @@ function getOrCreateEnumType(state, typeName) {
|
|
|
1317
1325
|
referencedByOutputType: false,
|
|
1318
1326
|
inputTypeReferences: new Set(),
|
|
1319
1327
|
outputTypeReferences: new Set(),
|
|
1328
|
+
ast: {
|
|
1329
|
+
directives: [],
|
|
1330
|
+
},
|
|
1320
1331
|
};
|
|
1321
1332
|
state.types.set(typeName, enumType);
|
|
1322
1333
|
return enumType;
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.enumTypeBuilder = void 0;
|
|
4
4
|
const ast_js_1 = require("./ast.js");
|
|
5
|
+
const common_js_1 = require("./common.js");
|
|
5
6
|
function enumTypeBuilder() {
|
|
6
7
|
return {
|
|
7
8
|
visitSubgraphState(graph, state, typeName, type) {
|
|
@@ -37,6 +38,9 @@ function enumTypeBuilder() {
|
|
|
37
38
|
enumTypeState.outputTypeReferences.add(ref);
|
|
38
39
|
});
|
|
39
40
|
}
|
|
41
|
+
type.ast.directives.forEach(directive => {
|
|
42
|
+
enumTypeState.ast.directives.push(directive);
|
|
43
|
+
});
|
|
40
44
|
enumTypeState.byGraph.set(graph.id, {
|
|
41
45
|
inaccessible: type.inaccessible,
|
|
42
46
|
version: graph.version,
|
|
@@ -89,6 +93,9 @@ function enumTypeBuilder() {
|
|
|
89
93
|
graph: graphName.toUpperCase(),
|
|
90
94
|
})),
|
|
91
95
|
},
|
|
96
|
+
ast: {
|
|
97
|
+
directives: (0, common_js_1.convertToConst)(enumType.ast.directives),
|
|
98
|
+
},
|
|
92
99
|
});
|
|
93
100
|
},
|
|
94
101
|
};
|
|
@@ -130,6 +137,9 @@ function getOrCreateEnumType(state, typeName) {
|
|
|
130
137
|
inputTypeReferences: new Set(),
|
|
131
138
|
outputTypeReferences: new Set(),
|
|
132
139
|
byGraph: new Map(),
|
|
140
|
+
ast: {
|
|
141
|
+
directives: [],
|
|
142
|
+
},
|
|
133
143
|
};
|
|
134
144
|
state.set(typeName, def);
|
|
135
145
|
return def;
|
package/esm/subgraph/state.js
CHANGED
|
@@ -358,6 +358,11 @@ export function createSubgraphStateBuilder(graph, typeDefs, version, links) {
|
|
|
358
358
|
}
|
|
359
359
|
break;
|
|
360
360
|
}
|
|
361
|
+
case Kind.ENUM_TYPE_DEFINITION:
|
|
362
|
+
case Kind.ENUM_TYPE_EXTENSION: {
|
|
363
|
+
enumTypeBuilder.setDirective(typeDef.name.value, node);
|
|
364
|
+
break;
|
|
365
|
+
}
|
|
361
366
|
default:
|
|
362
367
|
throw new Error(`Directives on "${typeDef.kind}" types are not supported yet`);
|
|
363
368
|
}
|
|
@@ -1120,6 +1125,9 @@ function enumTypeFactory(state) {
|
|
|
1120
1125
|
getOrCreateEnumType(state, typeName).referencedByOutputType = true;
|
|
1121
1126
|
getOrCreateEnumType(state, typeName).outputTypeReferences.add(schemaCoordinate);
|
|
1122
1127
|
},
|
|
1128
|
+
setDirective(typeName, directive) {
|
|
1129
|
+
getOrCreateEnumType(state, typeName).ast.directives.push(directive);
|
|
1130
|
+
},
|
|
1123
1131
|
value: {
|
|
1124
1132
|
setValue(typeName, valueName) {
|
|
1125
1133
|
getOrCreateEnumValue(state, typeName, valueName);
|
|
@@ -1311,6 +1319,9 @@ function getOrCreateEnumType(state, typeName) {
|
|
|
1311
1319
|
referencedByOutputType: false,
|
|
1312
1320
|
inputTypeReferences: new Set(),
|
|
1313
1321
|
outputTypeReferences: new Set(),
|
|
1322
|
+
ast: {
|
|
1323
|
+
directives: [],
|
|
1324
|
+
},
|
|
1314
1325
|
};
|
|
1315
1326
|
state.types.set(typeName, enumType);
|
|
1316
1327
|
return enumType;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { createEnumTypeNode } from './ast.js';
|
|
2
|
+
import { convertToConst } from './common.js';
|
|
2
3
|
export function enumTypeBuilder() {
|
|
3
4
|
return {
|
|
4
5
|
visitSubgraphState(graph, state, typeName, type) {
|
|
@@ -34,6 +35,9 @@ export function enumTypeBuilder() {
|
|
|
34
35
|
enumTypeState.outputTypeReferences.add(ref);
|
|
35
36
|
});
|
|
36
37
|
}
|
|
38
|
+
type.ast.directives.forEach(directive => {
|
|
39
|
+
enumTypeState.ast.directives.push(directive);
|
|
40
|
+
});
|
|
37
41
|
enumTypeState.byGraph.set(graph.id, {
|
|
38
42
|
inaccessible: type.inaccessible,
|
|
39
43
|
version: graph.version,
|
|
@@ -86,6 +90,9 @@ export function enumTypeBuilder() {
|
|
|
86
90
|
graph: graphName.toUpperCase(),
|
|
87
91
|
})),
|
|
88
92
|
},
|
|
93
|
+
ast: {
|
|
94
|
+
directives: convertToConst(enumType.ast.directives),
|
|
95
|
+
},
|
|
89
96
|
});
|
|
90
97
|
},
|
|
91
98
|
};
|
|
@@ -126,6 +133,9 @@ function getOrCreateEnumType(state, typeName) {
|
|
|
126
133
|
inputTypeReferences: new Set(),
|
|
127
134
|
outputTypeReferences: new Set(),
|
|
128
135
|
byGraph: new Map(),
|
|
136
|
+
ast: {
|
|
137
|
+
directives: [],
|
|
138
|
+
},
|
|
129
139
|
};
|
|
130
140
|
state.set(typeName, def);
|
|
131
141
|
return def;
|
package/package.json
CHANGED
|
@@ -120,6 +120,9 @@ export interface EnumType {
|
|
|
120
120
|
referencedByOutputType: boolean;
|
|
121
121
|
inputTypeReferences: Set<string>;
|
|
122
122
|
outputTypeReferences: Set<string>;
|
|
123
|
+
ast: {
|
|
124
|
+
directives: DirectiveNode[];
|
|
125
|
+
};
|
|
123
126
|
}
|
|
124
127
|
export interface Field {
|
|
125
128
|
name: string;
|
|
@@ -369,6 +372,7 @@ export declare function createSubgraphStateBuilder(graph: {
|
|
|
369
372
|
setTag(typeName: string, tag: string): void;
|
|
370
373
|
setReferencedByInputType(typeName: string, schemaCoordinate: string): void;
|
|
371
374
|
setReferencedByOutputType(typeName: string, schemaCoordinate: string): void;
|
|
375
|
+
setDirective(typeName: string, directive: DirectiveNode): void;
|
|
372
376
|
value: {
|
|
373
377
|
setValue(typeName: string, valueName: string): void;
|
|
374
378
|
setDescription(typeName: string, valueName: string, description: Description): void;
|
|
@@ -120,6 +120,9 @@ export interface EnumType {
|
|
|
120
120
|
referencedByOutputType: boolean;
|
|
121
121
|
inputTypeReferences: Set<string>;
|
|
122
122
|
outputTypeReferences: Set<string>;
|
|
123
|
+
ast: {
|
|
124
|
+
directives: DirectiveNode[];
|
|
125
|
+
};
|
|
123
126
|
}
|
|
124
127
|
export interface Field {
|
|
125
128
|
name: string;
|
|
@@ -369,6 +372,7 @@ export declare function createSubgraphStateBuilder(graph: {
|
|
|
369
372
|
setTag(typeName: string, tag: string): void;
|
|
370
373
|
setReferencedByInputType(typeName: string, schemaCoordinate: string): void;
|
|
371
374
|
setReferencedByOutputType(typeName: string, schemaCoordinate: string): void;
|
|
375
|
+
setDirective(typeName: string, directive: DirectiveNode): void;
|
|
372
376
|
value: {
|
|
373
377
|
setValue(typeName: string, valueName: string): void;
|
|
374
378
|
setDescription(typeName: string, valueName: string, description: Description): void;
|
|
@@ -169,6 +169,7 @@ export declare function createSubgraphValidationContext(subgraph: {
|
|
|
169
169
|
setTag(typeName: string, tag: string): void;
|
|
170
170
|
setReferencedByInputType(typeName: string, schemaCoordinate: string): void;
|
|
171
171
|
setReferencedByOutputType(typeName: string, schemaCoordinate: string): void;
|
|
172
|
+
setDirective(typeName: string, directive: import("graphql").DirectiveNode): void;
|
|
172
173
|
value: {
|
|
173
174
|
setValue(typeName: string, valueName: string): void;
|
|
174
175
|
setDescription(typeName: string, valueName: string, description: import("../state.js").Description): void;
|
|
@@ -169,6 +169,7 @@ export declare function createSubgraphValidationContext(subgraph: {
|
|
|
169
169
|
setTag(typeName: string, tag: string): void;
|
|
170
170
|
setReferencedByInputType(typeName: string, schemaCoordinate: string): void;
|
|
171
171
|
setReferencedByOutputType(typeName: string, schemaCoordinate: string): void;
|
|
172
|
+
setDirective(typeName: string, directive: import("graphql").DirectiveNode): void;
|
|
172
173
|
value: {
|
|
173
174
|
setValue(typeName: string, valueName: string): void;
|
|
174
175
|
setDescription(typeName: string, valueName: string, description: import("../state.js").Description): void;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
+
import type { DirectiveNode } from 'graphql';
|
|
1
2
|
import { FederationVersion } from '../../specifications/federation.cjs';
|
|
2
3
|
import { Deprecated, Description, EnumType } from '../../subgraph/state.cjs';
|
|
3
|
-
import type
|
|
4
|
+
import { type MapByGraph, type TypeBuilder } from './common.cjs';
|
|
4
5
|
export declare function enumTypeBuilder(): TypeBuilder<EnumType, EnumTypeState>;
|
|
5
6
|
export type EnumTypeState = {
|
|
6
7
|
kind: 'enum';
|
|
@@ -18,6 +19,9 @@ export type EnumTypeState = {
|
|
|
18
19
|
inputTypeReferences: Set<string>;
|
|
19
20
|
outputTypeReferences: Set<string>;
|
|
20
21
|
values: Map<string, EnumValueState>;
|
|
22
|
+
ast: {
|
|
23
|
+
directives: DirectiveNode[];
|
|
24
|
+
};
|
|
21
25
|
};
|
|
22
26
|
type EnumValueState = {
|
|
23
27
|
name: string;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
+
import type { DirectiveNode } from 'graphql';
|
|
1
2
|
import { FederationVersion } from '../../specifications/federation.js';
|
|
2
3
|
import { Deprecated, Description, EnumType } from '../../subgraph/state.js';
|
|
3
|
-
import type
|
|
4
|
+
import { type MapByGraph, type TypeBuilder } from './common.js';
|
|
4
5
|
export declare function enumTypeBuilder(): TypeBuilder<EnumType, EnumTypeState>;
|
|
5
6
|
export type EnumTypeState = {
|
|
6
7
|
kind: 'enum';
|
|
@@ -18,6 +19,9 @@ export type EnumTypeState = {
|
|
|
18
19
|
inputTypeReferences: Set<string>;
|
|
19
20
|
outputTypeReferences: Set<string>;
|
|
20
21
|
values: Map<string, EnumValueState>;
|
|
22
|
+
ast: {
|
|
23
|
+
directives: DirectiveNode[];
|
|
24
|
+
};
|
|
21
25
|
};
|
|
22
26
|
type EnumValueState = {
|
|
23
27
|
name: string;
|