@theguild/federation-composition 0.9.0 → 0.10.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/README.md +2 -1
- package/cjs/specifications/link.js +40 -5
- package/cjs/subgraph/helpers.js +2 -2
- package/cjs/subgraph/state.js +8 -0
- package/cjs/subgraph/validation/rules/elements/provides.js +8 -6
- package/cjs/subgraph/validation/rules/elements/requires.js +9 -7
- package/cjs/subgraph/validation/validate-state.js +9 -3
- package/cjs/subgraph/validation/validate-subgraph.js +4 -2
- package/cjs/subgraph/validation/validation-context.js +10 -0
- package/cjs/supergraph/composition/directive.js +3 -0
- package/cjs/supergraph/composition/enum-type.js +3 -0
- package/cjs/supergraph/composition/input-object-type.js +3 -0
- package/cjs/supergraph/composition/interface-type.js +4 -0
- package/cjs/supergraph/composition/object-type.js +18 -20
- package/cjs/supergraph/composition/scalar-type.js +2 -0
- package/cjs/supergraph/composition/union-type.js +2 -0
- package/cjs/supergraph/state.js +24 -26
- package/cjs/supergraph/validation/rules/fields-of-the-same-type-rule.js +35 -0
- package/cjs/supergraph/validation/rules/invalid-field-sharing-rule.js +4 -1
- package/cjs/supergraph/validation/rules/satisfiablity/constants.js +4 -0
- package/cjs/supergraph/validation/rules/satisfiablity/edge.js +64 -0
- package/cjs/supergraph/validation/rules/satisfiablity/errors.js +44 -0
- package/cjs/supergraph/validation/rules/satisfiablity/fields.js +147 -0
- package/cjs/supergraph/validation/rules/satisfiablity/finder.js +267 -0
- package/cjs/supergraph/validation/rules/satisfiablity/graph.js +675 -0
- package/cjs/supergraph/validation/rules/satisfiablity/helpers.js +41 -0
- package/cjs/supergraph/validation/rules/satisfiablity/move-validator.js +337 -0
- package/cjs/supergraph/validation/rules/satisfiablity/moves.js +52 -0
- package/cjs/supergraph/validation/rules/satisfiablity/node.js +89 -0
- package/cjs/supergraph/validation/rules/satisfiablity/operation-path.js +70 -0
- package/cjs/supergraph/validation/rules/satisfiablity/supergraph.js +37 -0
- package/cjs/supergraph/validation/rules/satisfiablity/walker.js +306 -0
- package/cjs/supergraph/validation/rules/satisfiablity-rule.js +45 -1081
- package/cjs/supergraph/validation/validate-supergraph.js +1 -1
- package/cjs/utils/logger.js +127 -0
- package/esm/specifications/link.js +40 -5
- package/esm/subgraph/helpers.js +2 -2
- package/esm/subgraph/state.js +8 -0
- package/esm/subgraph/validation/rules/elements/provides.js +8 -6
- package/esm/subgraph/validation/rules/elements/requires.js +9 -7
- package/esm/subgraph/validation/validate-state.js +9 -3
- package/esm/subgraph/validation/validate-subgraph.js +4 -2
- package/esm/subgraph/validation/validation-context.js +11 -1
- package/esm/supergraph/composition/directive.js +3 -0
- package/esm/supergraph/composition/enum-type.js +3 -0
- package/esm/supergraph/composition/input-object-type.js +3 -0
- package/esm/supergraph/composition/interface-type.js +4 -0
- package/esm/supergraph/composition/object-type.js +18 -20
- package/esm/supergraph/composition/scalar-type.js +2 -0
- package/esm/supergraph/composition/union-type.js +2 -0
- package/esm/supergraph/state.js +24 -26
- package/esm/supergraph/validation/rules/fields-of-the-same-type-rule.js +35 -0
- package/esm/supergraph/validation/rules/invalid-field-sharing-rule.js +4 -1
- package/esm/supergraph/validation/rules/satisfiablity/constants.js +1 -0
- package/esm/supergraph/validation/rules/satisfiablity/edge.js +54 -0
- package/esm/supergraph/validation/rules/satisfiablity/errors.js +40 -0
- package/esm/supergraph/validation/rules/satisfiablity/fields.js +142 -0
- package/esm/supergraph/validation/rules/satisfiablity/finder.js +261 -0
- package/esm/supergraph/validation/rules/satisfiablity/graph.js +671 -0
- package/esm/supergraph/validation/rules/satisfiablity/helpers.js +35 -0
- package/esm/supergraph/validation/rules/satisfiablity/move-validator.js +333 -0
- package/esm/supergraph/validation/rules/satisfiablity/moves.js +46 -0
- package/esm/supergraph/validation/rules/satisfiablity/node.js +85 -0
- package/esm/supergraph/validation/rules/satisfiablity/operation-path.js +66 -0
- package/esm/supergraph/validation/rules/satisfiablity/supergraph.js +33 -0
- package/esm/supergraph/validation/rules/satisfiablity/walker.js +301 -0
- package/esm/supergraph/validation/rules/satisfiablity-rule.js +40 -1076
- package/esm/supergraph/validation/validate-supergraph.js +1 -1
- package/esm/utils/logger.js +119 -0
- package/package.json +2 -1
- package/typings/subgraph/state.d.cts +2 -0
- package/typings/subgraph/state.d.ts +2 -0
- package/typings/subgraph/validation/validate-state.d.cts +2 -1
- package/typings/subgraph/validation/validate-state.d.ts +2 -1
- package/typings/subgraph/validation/validation-context.d.cts +3 -0
- package/typings/subgraph/validation/validation-context.d.ts +3 -0
- package/typings/supergraph/composition/common.d.cts +2 -1
- package/typings/supergraph/composition/common.d.ts +2 -1
- package/typings/supergraph/composition/directive.d.cts +4 -0
- package/typings/supergraph/composition/directive.d.ts +4 -0
- package/typings/supergraph/composition/enum-type.d.cts +4 -0
- package/typings/supergraph/composition/enum-type.d.ts +4 -0
- package/typings/supergraph/composition/input-object-type.d.cts +4 -0
- package/typings/supergraph/composition/input-object-type.d.ts +4 -0
- package/typings/supergraph/composition/interface-type.d.cts +5 -0
- package/typings/supergraph/composition/interface-type.d.ts +5 -0
- package/typings/supergraph/composition/object-type.d.cts +5 -0
- package/typings/supergraph/composition/object-type.d.ts +5 -0
- package/typings/supergraph/composition/scalar-type.d.cts +3 -0
- package/typings/supergraph/composition/scalar-type.d.ts +3 -0
- package/typings/supergraph/composition/union-type.d.cts +3 -0
- package/typings/supergraph/composition/union-type.d.ts +3 -0
- package/typings/supergraph/state.d.cts +4 -4
- package/typings/supergraph/state.d.ts +4 -4
- package/typings/supergraph/validation/rules/satisfiablity/constants.d.cts +2 -0
- package/typings/supergraph/validation/rules/satisfiablity/constants.d.ts +2 -0
- package/typings/supergraph/validation/rules/satisfiablity/edge.d.cts +31 -0
- package/typings/supergraph/validation/rules/satisfiablity/edge.d.ts +31 -0
- package/typings/supergraph/validation/rules/satisfiablity/errors.d.cts +17 -0
- package/typings/supergraph/validation/rules/satisfiablity/errors.d.ts +17 -0
- package/typings/supergraph/validation/rules/satisfiablity/fields.d.cts +33 -0
- package/typings/supergraph/validation/rules/satisfiablity/fields.d.ts +33 -0
- package/typings/supergraph/validation/rules/satisfiablity/finder.d.cts +28 -0
- package/typings/supergraph/validation/rules/satisfiablity/finder.d.ts +28 -0
- package/typings/supergraph/validation/rules/satisfiablity/graph.d.cts +63 -0
- package/typings/supergraph/validation/rules/satisfiablity/graph.d.ts +63 -0
- package/typings/supergraph/validation/rules/satisfiablity/helpers.d.cts +7 -0
- package/typings/supergraph/validation/rules/satisfiablity/helpers.d.ts +7 -0
- package/typings/supergraph/validation/rules/satisfiablity/move-validator.d.cts +25 -0
- package/typings/supergraph/validation/rules/satisfiablity/move-validator.d.ts +25 -0
- package/typings/supergraph/validation/rules/satisfiablity/moves.d.cts +24 -0
- package/typings/supergraph/validation/rules/satisfiablity/moves.d.ts +24 -0
- package/typings/supergraph/validation/rules/satisfiablity/node.d.cts +31 -0
- package/typings/supergraph/validation/rules/satisfiablity/node.d.ts +31 -0
- package/typings/supergraph/validation/rules/satisfiablity/operation-path.d.cts +29 -0
- package/typings/supergraph/validation/rules/satisfiablity/operation-path.d.ts +29 -0
- package/typings/supergraph/validation/rules/satisfiablity/supergraph.d.cts +14 -0
- package/typings/supergraph/validation/rules/satisfiablity/supergraph.d.ts +14 -0
- package/typings/supergraph/validation/rules/satisfiablity/walker.d.cts +35 -0
- package/typings/supergraph/validation/rules/satisfiablity/walker.d.ts +35 -0
- package/typings/utils/logger.d.cts +33 -0
- package/typings/utils/logger.d.ts +33 -0
- package/cjs/utils/dependency-graph.js +0 -227
- package/esm/utils/dependency-graph.js +0 -222
- package/typings/utils/dependency-graph.d.cts +0 -31
- package/typings/utils/dependency-graph.d.ts +0 -31
|
@@ -27,7 +27,7 @@ import { createSupergraphValidationContext } from './validation-context.js';
|
|
|
27
27
|
export function validateSupergraph(subgraphStates, state, __internal) {
|
|
28
28
|
const context = createSupergraphValidationContext(subgraphStates);
|
|
29
29
|
for (const subgraphState of subgraphStates.values()) {
|
|
30
|
-
state.
|
|
30
|
+
state.addSubgraph(subgraphState);
|
|
31
31
|
}
|
|
32
32
|
const preSupergraphRules = [RequiredQueryRule, TypesOfTheSameKindRule];
|
|
33
33
|
const rulesToSkip = __internal?.disableValidationRules ?? [];
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import debug from 'debug';
|
|
2
|
+
const originalFormatArgs = debug.formatArgs;
|
|
3
|
+
debug.formatArgs = function (args) {
|
|
4
|
+
originalFormatArgs.call(this, args);
|
|
5
|
+
const line = args[0];
|
|
6
|
+
const noColorsPrefix = ` ${this.namespace} `;
|
|
7
|
+
const colorsPrefix = `${this.namespace}`;
|
|
8
|
+
const noColorsStartsAt = line.indexOf(noColorsPrefix);
|
|
9
|
+
if (noColorsStartsAt > -1) {
|
|
10
|
+
args[0] = line.slice(noColorsStartsAt + noColorsPrefix.length);
|
|
11
|
+
}
|
|
12
|
+
else {
|
|
13
|
+
const colorsStartsAt = line.indexOf(colorsPrefix);
|
|
14
|
+
args[0] = line.slice(colorsStartsAt + colorsPrefix.length);
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
export class LoggerContext {
|
|
18
|
+
indent = {
|
|
19
|
+
level: 0,
|
|
20
|
+
str: '',
|
|
21
|
+
times: [],
|
|
22
|
+
};
|
|
23
|
+
maxIdLength = 0;
|
|
24
|
+
idUpdateFns = [];
|
|
25
|
+
logger = debug('composition');
|
|
26
|
+
firstLoggerAt = 0;
|
|
27
|
+
down(time) {
|
|
28
|
+
this.updateIndent(+1, time);
|
|
29
|
+
}
|
|
30
|
+
up(time) {
|
|
31
|
+
if (this.indent.level > 0) {
|
|
32
|
+
this.updateIndent(-1, time);
|
|
33
|
+
return this.indent.times.pop();
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
getTime() {
|
|
37
|
+
if (!this.firstLoggerAt) {
|
|
38
|
+
this.firstLoggerAt = Date.now();
|
|
39
|
+
return 0;
|
|
40
|
+
}
|
|
41
|
+
return Date.now() - this.firstLoggerAt;
|
|
42
|
+
}
|
|
43
|
+
getIndent() {
|
|
44
|
+
return this.indent;
|
|
45
|
+
}
|
|
46
|
+
register(id, idUpdateFn) {
|
|
47
|
+
idUpdateFn(this.maxIdLength);
|
|
48
|
+
this.idUpdateFns.push(idUpdateFn);
|
|
49
|
+
const newMaxIdLength = Math.max(this.maxIdLength, id.length);
|
|
50
|
+
if (newMaxIdLength > this.maxIdLength) {
|
|
51
|
+
this.maxIdLength = newMaxIdLength;
|
|
52
|
+
this.idUpdateFns.forEach(fn => fn(newMaxIdLength));
|
|
53
|
+
}
|
|
54
|
+
return this.logger.extend(id);
|
|
55
|
+
}
|
|
56
|
+
updateIndent(delta, time) {
|
|
57
|
+
if (this.indent.level + delta < 0) {
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
if (delta > 0) {
|
|
61
|
+
this.indent.times.push(time);
|
|
62
|
+
}
|
|
63
|
+
this.indent.level += delta;
|
|
64
|
+
this.indent.str = '│ '.repeat(this.indent.level);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
export class Logger {
|
|
68
|
+
id;
|
|
69
|
+
context;
|
|
70
|
+
isEnabled;
|
|
71
|
+
debug;
|
|
72
|
+
idPrefix;
|
|
73
|
+
constructor(id, context) {
|
|
74
|
+
this.id = id;
|
|
75
|
+
this.context = context;
|
|
76
|
+
this.id = id;
|
|
77
|
+
this.context = context;
|
|
78
|
+
this.idPrefix = `${id}`;
|
|
79
|
+
this.debug = this.context.register(this.id, this._updateIdPrefix.bind(this));
|
|
80
|
+
this.isEnabled = this.debug.enabled;
|
|
81
|
+
this.debug.log = console.log;
|
|
82
|
+
}
|
|
83
|
+
log(msg, prefix = '- ') {
|
|
84
|
+
if (this.isEnabled) {
|
|
85
|
+
this._log(prefix, msg);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
group(msg) {
|
|
89
|
+
if (this.isEnabled) {
|
|
90
|
+
this.log(msg, '┌ ');
|
|
91
|
+
this.context.down(Date.now());
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
groupEnd(msg) {
|
|
95
|
+
if (this.isEnabled) {
|
|
96
|
+
const time = this.context.up(Date.now());
|
|
97
|
+
let message = msg ? (typeof msg === 'string' ? msg : msg()) : '';
|
|
98
|
+
if (time) {
|
|
99
|
+
message += ` (${Date.now() - time}ms)`;
|
|
100
|
+
}
|
|
101
|
+
this.log(message, '└ ');
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
create(id) {
|
|
105
|
+
return new Logger(id, this.context);
|
|
106
|
+
}
|
|
107
|
+
_log(prefix, msg) {
|
|
108
|
+
const indent = this.context.getIndent().str;
|
|
109
|
+
const message = typeof msg === 'string' ? msg : msg();
|
|
110
|
+
if (this.isEnabled) {
|
|
111
|
+
const sinceStart = this.context.getTime();
|
|
112
|
+
const text = this.idPrefix + ' ' + indent + prefix + message + ` +${sinceStart}ms`;
|
|
113
|
+
this.debug(text);
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
_updateIdPrefix(maxLength) {
|
|
117
|
+
this.idPrefix = this.id.padEnd(maxLength, ' ');
|
|
118
|
+
}
|
|
119
|
+
}
|
package/package.json
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@theguild/federation-composition",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.10.0",
|
|
4
4
|
"description": "Open Source Composition library for Apollo Federation",
|
|
5
5
|
"peerDependencies": {
|
|
6
6
|
"graphql": "^16.0.0"
|
|
7
7
|
},
|
|
8
8
|
"dependencies": {
|
|
9
9
|
"constant-case": "^3.0.0",
|
|
10
|
+
"debug": "4.3.4",
|
|
10
11
|
"json5": "^2.2.0",
|
|
11
12
|
"lodash.sortby": "^4.7.0"
|
|
12
13
|
},
|
|
@@ -123,6 +123,7 @@ export interface Field {
|
|
|
123
123
|
override: string | null;
|
|
124
124
|
provides: string | null;
|
|
125
125
|
requires: string | null;
|
|
126
|
+
extension: boolean;
|
|
126
127
|
required: boolean;
|
|
127
128
|
provided: boolean;
|
|
128
129
|
shareable: boolean;
|
|
@@ -243,6 +244,7 @@ export declare function createSubgraphStateBuilder(graph: {
|
|
|
243
244
|
setDirective(typeName: string, directive: DirectiveNode): void;
|
|
244
245
|
field: {
|
|
245
246
|
setType(typeName: string, fieldName: string, fieldType: string): void;
|
|
247
|
+
setExtension(typeName: string, fieldName: string): void;
|
|
246
248
|
setDirective(typeName: string, fieldName: string, directive: DirectiveNode): void;
|
|
247
249
|
setDescription(typeName: string, fieldName: string, description: Description): void;
|
|
248
250
|
setDeprecated(typeName: string, fieldName: string, reason?: string | undefined): void;
|
|
@@ -123,6 +123,7 @@ export interface Field {
|
|
|
123
123
|
override: string | null;
|
|
124
124
|
provides: string | null;
|
|
125
125
|
requires: string | null;
|
|
126
|
+
extension: boolean;
|
|
126
127
|
required: boolean;
|
|
127
128
|
provided: boolean;
|
|
128
129
|
shareable: boolean;
|
|
@@ -243,6 +244,7 @@ export declare function createSubgraphStateBuilder(graph: {
|
|
|
243
244
|
setDirective(typeName: string, directive: DirectiveNode): void;
|
|
244
245
|
field: {
|
|
245
246
|
setType(typeName: string, fieldName: string, fieldType: string): void;
|
|
247
|
+
setExtension(typeName: string, fieldName: string): void;
|
|
246
248
|
setDirective(typeName: string, fieldName: string, directive: DirectiveNode): void;
|
|
247
249
|
setDescription(typeName: string, fieldName: string, description: Description): void;
|
|
248
250
|
setDeprecated(typeName: string, fieldName: string, reason?: string | undefined): void;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { GraphQLError } from 'graphql';
|
|
2
2
|
import { Directive, EnumType, InputObjectType, InterfaceType, ObjectType, ScalarType, SubgraphState, SubgraphType, UnionType } from '../state.cjs';
|
|
3
|
-
|
|
3
|
+
import { SubgraphValidationContext } from './validation-context.cjs';
|
|
4
|
+
export declare function validateSubgraphState(state: SubgraphState, context: SubgraphValidationContext): GraphQLError[];
|
|
4
5
|
export declare function isTypeSubTypeOf(state: SubgraphState, implementationsMap: Map<string, Set<string>>, maybeSubTypeName: string, superTypeName: string): boolean;
|
|
5
6
|
export declare function isInputType(state: SubgraphState, typeName: string): boolean;
|
|
6
7
|
export declare function typeExists(state: SubgraphState, typeName: string): boolean;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { GraphQLError } from 'graphql';
|
|
2
2
|
import { Directive, EnumType, InputObjectType, InterfaceType, ObjectType, ScalarType, SubgraphState, SubgraphType, UnionType } from '../state.js';
|
|
3
|
-
|
|
3
|
+
import { SubgraphValidationContext } from './validation-context.js';
|
|
4
|
+
export declare function validateSubgraphState(state: SubgraphState, context: SubgraphValidationContext): GraphQLError[];
|
|
4
5
|
export declare function isTypeSubTypeOf(state: SubgraphState, implementationsMap: Map<string, Set<string>>, maybeSubTypeName: string, superTypeName: string): boolean;
|
|
5
6
|
export declare function isInputType(state: SubgraphState, typeName: string): boolean;
|
|
6
7
|
export declare function typeExists(state: SubgraphState, typeName: string): boolean;
|
|
@@ -61,6 +61,7 @@ export declare function createSubgraphValidationContext(subgraph: {
|
|
|
61
61
|
setDirective(typeName: string, directive: import("graphql").DirectiveNode): void;
|
|
62
62
|
field: {
|
|
63
63
|
setType(typeName: string, fieldName: string, fieldType: string): void;
|
|
64
|
+
setExtension(typeName: string, fieldName: string): void;
|
|
64
65
|
setDirective(typeName: string, fieldName: string, directive: import("graphql").DirectiveNode): void;
|
|
65
66
|
setDescription(typeName: string, fieldName: string, description: import("../state.js").Description): void;
|
|
66
67
|
setDeprecated(typeName: string, fieldName: string, reason?: string | undefined): void;
|
|
@@ -171,6 +172,8 @@ export declare function createSubgraphValidationContext(subgraph: {
|
|
|
171
172
|
markSpecAsUsed(specName: "link" | "tag" | "inaccessible" | "policy" | "requiresScopes" | "authenticated"): void;
|
|
172
173
|
visitor(typeNodeInfo: TypeNodeInfo): import("graphql").ASTVisitor;
|
|
173
174
|
};
|
|
175
|
+
isLinkSpecDirective(name: string): boolean;
|
|
176
|
+
isLinkSpecType(name: string): boolean;
|
|
174
177
|
isAvailableFederationType(name: string): boolean;
|
|
175
178
|
isAvailableFederationDirective(specDirectiveName: string, directiveNode: {
|
|
176
179
|
name: {
|
|
@@ -61,6 +61,7 @@ export declare function createSubgraphValidationContext(subgraph: {
|
|
|
61
61
|
setDirective(typeName: string, directive: import("graphql").DirectiveNode): void;
|
|
62
62
|
field: {
|
|
63
63
|
setType(typeName: string, fieldName: string, fieldType: string): void;
|
|
64
|
+
setExtension(typeName: string, fieldName: string): void;
|
|
64
65
|
setDirective(typeName: string, fieldName: string, directive: import("graphql").DirectiveNode): void;
|
|
65
66
|
setDescription(typeName: string, fieldName: string, description: import("../state.js").Description): void;
|
|
66
67
|
setDeprecated(typeName: string, fieldName: string, reason?: string | undefined): void;
|
|
@@ -171,6 +172,8 @@ export declare function createSubgraphValidationContext(subgraph: {
|
|
|
171
172
|
markSpecAsUsed(specName: "link" | "tag" | "inaccessible" | "policy" | "requiresScopes" | "authenticated"): void;
|
|
172
173
|
visitor(typeNodeInfo: TypeNodeInfo): import("graphql").ASTVisitor;
|
|
173
174
|
};
|
|
175
|
+
isLinkSpecDirective(name: string): boolean;
|
|
176
|
+
isLinkSpecType(name: string): boolean;
|
|
174
177
|
isAvailableFederationType(name: string): boolean;
|
|
175
178
|
isAvailableFederationDirective(specDirectiveName: string, directiveNode: {
|
|
176
179
|
name: {
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { ConstDirectiveNode, DirectiveDefinitionNode, DirectiveNode, TypeDefinitionNode } from 'graphql';
|
|
2
2
|
import type { FederationVersion } from '../../specifications/federation.cjs';
|
|
3
|
+
import { SubgraphState } from '../../subgraph/state.cjs';
|
|
3
4
|
import type { SupergraphState } from '../state.cjs';
|
|
4
5
|
export type MapByGraph<T> = Map<string, T>;
|
|
5
6
|
export interface Key {
|
|
@@ -14,7 +15,7 @@ export interface Graph {
|
|
|
14
15
|
}
|
|
15
16
|
export interface TypeBuilder<T, S> {
|
|
16
17
|
visitSubgraphState(graph: Graph, state: Map<string, S>, typeName: string, type: T): void;
|
|
17
|
-
composeSupergraphNode(type: S, graphMap: Map<string,
|
|
18
|
+
composeSupergraphNode(type: S, graphMap: Map<string, SubgraphState>, helpers: {
|
|
18
19
|
graphNameToId(graphName: string): string | null;
|
|
19
20
|
supergraphState: SupergraphState;
|
|
20
21
|
}): TypeDefinitionNode | DirectiveDefinitionNode;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { ConstDirectiveNode, DirectiveDefinitionNode, DirectiveNode, TypeDefinitionNode } from 'graphql';
|
|
2
2
|
import type { FederationVersion } from '../../specifications/federation.js';
|
|
3
|
+
import { SubgraphState } from '../../subgraph/state.js';
|
|
3
4
|
import type { SupergraphState } from '../state.js';
|
|
4
5
|
export type MapByGraph<T> = Map<string, T>;
|
|
5
6
|
export interface Key {
|
|
@@ -14,7 +15,7 @@ export interface Graph {
|
|
|
14
15
|
}
|
|
15
16
|
export interface TypeBuilder<T, S> {
|
|
16
17
|
visitSubgraphState(graph: Graph, state: Map<string, S>, typeName: string, type: T): void;
|
|
17
|
-
composeSupergraphNode(type: S, graphMap: Map<string,
|
|
18
|
+
composeSupergraphNode(type: S, graphMap: Map<string, SubgraphState>, helpers: {
|
|
18
19
|
graphNameToId(graphName: string): string | null;
|
|
19
20
|
supergraphState: SupergraphState;
|
|
20
21
|
}): TypeDefinitionNode | DirectiveDefinitionNode;
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import { DirectiveNode } from 'graphql';
|
|
2
|
+
import { FederationVersion } from '../../specifications/federation.cjs';
|
|
2
3
|
import type { Directive } from '../../subgraph/state.cjs';
|
|
3
4
|
import { MapByGraph, TypeBuilder } from './common.cjs';
|
|
4
5
|
export declare function directiveBuilder(): TypeBuilder<Directive, DirectiveState>;
|
|
5
6
|
export type DirectiveState = {
|
|
7
|
+
kind: 'directive';
|
|
6
8
|
name: string;
|
|
7
9
|
byGraph: MapByGraph<DirectiveStateInGraph>;
|
|
8
10
|
locations: Set<string>;
|
|
@@ -12,6 +14,7 @@ export type DirectiveState = {
|
|
|
12
14
|
type DirectiveStateInGraph = {
|
|
13
15
|
locations: Set<string>;
|
|
14
16
|
repeatable: boolean;
|
|
17
|
+
version: FederationVersion;
|
|
15
18
|
};
|
|
16
19
|
export type DirectiveArgState = {
|
|
17
20
|
name: string;
|
|
@@ -27,6 +30,7 @@ export type DirectiveArgState = {
|
|
|
27
30
|
type ArgStateInGraph = {
|
|
28
31
|
type: string;
|
|
29
32
|
defaultValue?: string;
|
|
33
|
+
version: FederationVersion;
|
|
30
34
|
};
|
|
31
35
|
export {};
|
|
32
36
|
//# sourceMappingURL=directive.d.ts.map
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import { DirectiveNode } from 'graphql';
|
|
2
|
+
import { FederationVersion } from '../../specifications/federation.js';
|
|
2
3
|
import type { Directive } from '../../subgraph/state.js';
|
|
3
4
|
import { MapByGraph, TypeBuilder } from './common.js';
|
|
4
5
|
export declare function directiveBuilder(): TypeBuilder<Directive, DirectiveState>;
|
|
5
6
|
export type DirectiveState = {
|
|
7
|
+
kind: 'directive';
|
|
6
8
|
name: string;
|
|
7
9
|
byGraph: MapByGraph<DirectiveStateInGraph>;
|
|
8
10
|
locations: Set<string>;
|
|
@@ -12,6 +14,7 @@ export type DirectiveState = {
|
|
|
12
14
|
type DirectiveStateInGraph = {
|
|
13
15
|
locations: Set<string>;
|
|
14
16
|
repeatable: boolean;
|
|
17
|
+
version: FederationVersion;
|
|
15
18
|
};
|
|
16
19
|
export type DirectiveArgState = {
|
|
17
20
|
name: string;
|
|
@@ -27,6 +30,7 @@ export type DirectiveArgState = {
|
|
|
27
30
|
type ArgStateInGraph = {
|
|
28
31
|
type: string;
|
|
29
32
|
defaultValue?: string;
|
|
33
|
+
version: FederationVersion;
|
|
30
34
|
};
|
|
31
35
|
export {};
|
|
32
36
|
//# sourceMappingURL=directive.d.ts.map
|
|
@@ -1,7 +1,9 @@
|
|
|
1
|
+
import { FederationVersion } from '../../specifications/federation.cjs';
|
|
1
2
|
import { Deprecated, Description, EnumType } from '../../subgraph/state.cjs';
|
|
2
3
|
import type { MapByGraph, TypeBuilder } from './common.cjs';
|
|
3
4
|
export declare function enumTypeBuilder(): TypeBuilder<EnumType, EnumTypeState>;
|
|
4
5
|
export type EnumTypeState = {
|
|
6
|
+
kind: 'enum';
|
|
5
7
|
name: string;
|
|
6
8
|
tags: Set<string>;
|
|
7
9
|
inaccessible: boolean;
|
|
@@ -27,9 +29,11 @@ type EnumValueState = {
|
|
|
27
29
|
};
|
|
28
30
|
type EnumTypeStateInGraph = {
|
|
29
31
|
inaccessible: boolean;
|
|
32
|
+
version: FederationVersion;
|
|
30
33
|
};
|
|
31
34
|
type EnumValueStateInGraph = {
|
|
32
35
|
inaccessible: boolean;
|
|
36
|
+
version: FederationVersion;
|
|
33
37
|
};
|
|
34
38
|
export {};
|
|
35
39
|
//# sourceMappingURL=enum-type.d.ts.map
|
|
@@ -1,7 +1,9 @@
|
|
|
1
|
+
import { FederationVersion } from '../../specifications/federation.js';
|
|
1
2
|
import { Deprecated, Description, EnumType } from '../../subgraph/state.js';
|
|
2
3
|
import type { MapByGraph, TypeBuilder } from './common.js';
|
|
3
4
|
export declare function enumTypeBuilder(): TypeBuilder<EnumType, EnumTypeState>;
|
|
4
5
|
export type EnumTypeState = {
|
|
6
|
+
kind: 'enum';
|
|
5
7
|
name: string;
|
|
6
8
|
tags: Set<string>;
|
|
7
9
|
inaccessible: boolean;
|
|
@@ -27,9 +29,11 @@ type EnumValueState = {
|
|
|
27
29
|
};
|
|
28
30
|
type EnumTypeStateInGraph = {
|
|
29
31
|
inaccessible: boolean;
|
|
32
|
+
version: FederationVersion;
|
|
30
33
|
};
|
|
31
34
|
type EnumValueStateInGraph = {
|
|
32
35
|
inaccessible: boolean;
|
|
36
|
+
version: FederationVersion;
|
|
33
37
|
};
|
|
34
38
|
export {};
|
|
35
39
|
//# sourceMappingURL=enum-type.d.ts.map
|
|
@@ -1,7 +1,9 @@
|
|
|
1
|
+
import { FederationVersion } from '../../specifications/federation.cjs';
|
|
1
2
|
import { Deprecated, Description, InputObjectType } from '../../subgraph/state.cjs';
|
|
2
3
|
import type { MapByGraph, TypeBuilder } from './common.cjs';
|
|
3
4
|
export declare function inputObjectTypeBuilder(): TypeBuilder<InputObjectType, InputObjectTypeState>;
|
|
4
5
|
export interface InputObjectTypeState {
|
|
6
|
+
kind: 'input';
|
|
5
7
|
name: string;
|
|
6
8
|
tags: Set<string>;
|
|
7
9
|
inaccessible: boolean;
|
|
@@ -22,11 +24,13 @@ export type InputObjectTypeFieldState = {
|
|
|
22
24
|
};
|
|
23
25
|
type InputObjectTypeStateInGraph = {
|
|
24
26
|
inaccessible: boolean;
|
|
27
|
+
version: FederationVersion;
|
|
25
28
|
};
|
|
26
29
|
type InputObjectFieldStateInGraph = {
|
|
27
30
|
type: string;
|
|
28
31
|
inaccessible: boolean;
|
|
29
32
|
defaultValue?: string;
|
|
33
|
+
version: FederationVersion;
|
|
30
34
|
};
|
|
31
35
|
export {};
|
|
32
36
|
//# sourceMappingURL=input-object-type.d.ts.map
|
|
@@ -1,7 +1,9 @@
|
|
|
1
|
+
import { FederationVersion } from '../../specifications/federation.js';
|
|
1
2
|
import { Deprecated, Description, InputObjectType } from '../../subgraph/state.js';
|
|
2
3
|
import type { MapByGraph, TypeBuilder } from './common.js';
|
|
3
4
|
export declare function inputObjectTypeBuilder(): TypeBuilder<InputObjectType, InputObjectTypeState>;
|
|
4
5
|
export interface InputObjectTypeState {
|
|
6
|
+
kind: 'input';
|
|
5
7
|
name: string;
|
|
6
8
|
tags: Set<string>;
|
|
7
9
|
inaccessible: boolean;
|
|
@@ -22,11 +24,13 @@ export type InputObjectTypeFieldState = {
|
|
|
22
24
|
};
|
|
23
25
|
type InputObjectTypeStateInGraph = {
|
|
24
26
|
inaccessible: boolean;
|
|
27
|
+
version: FederationVersion;
|
|
25
28
|
};
|
|
26
29
|
type InputObjectFieldStateInGraph = {
|
|
27
30
|
type: string;
|
|
28
31
|
inaccessible: boolean;
|
|
29
32
|
defaultValue?: string;
|
|
33
|
+
version: FederationVersion;
|
|
30
34
|
};
|
|
31
35
|
export {};
|
|
32
36
|
//# sourceMappingURL=input-object-type.d.ts.map
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import { DirectiveNode } from 'graphql';
|
|
2
|
+
import { FederationVersion } from '../../specifications/federation.cjs';
|
|
2
3
|
import { Deprecated, Description, InterfaceType } from '../../subgraph/state.cjs';
|
|
3
4
|
import type { Key, MapByGraph, TypeBuilder } from './common.cjs';
|
|
4
5
|
export declare function interfaceTypeBuilder(): TypeBuilder<InterfaceType, InterfaceTypeState>;
|
|
5
6
|
export type InterfaceTypeState = {
|
|
7
|
+
kind: 'interface';
|
|
6
8
|
name: string;
|
|
7
9
|
tags: Set<string>;
|
|
8
10
|
inaccessible: boolean;
|
|
@@ -52,16 +54,19 @@ type InterfaceTypeInGraph = {
|
|
|
52
54
|
keys: Key[];
|
|
53
55
|
interfaces: Set<string>;
|
|
54
56
|
implementedBy: Set<string>;
|
|
57
|
+
version: FederationVersion;
|
|
55
58
|
};
|
|
56
59
|
type FieldStateInGraph = {
|
|
57
60
|
type: string;
|
|
58
61
|
override: string | null;
|
|
59
62
|
provides: string | null;
|
|
60
63
|
requires: string | null;
|
|
64
|
+
version: FederationVersion;
|
|
61
65
|
};
|
|
62
66
|
type ArgStateInGraph = {
|
|
63
67
|
type: string;
|
|
64
68
|
defaultValue?: string;
|
|
69
|
+
version: FederationVersion;
|
|
65
70
|
};
|
|
66
71
|
export {};
|
|
67
72
|
//# sourceMappingURL=interface-type.d.ts.map
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import { DirectiveNode } from 'graphql';
|
|
2
|
+
import { FederationVersion } from '../../specifications/federation.js';
|
|
2
3
|
import { Deprecated, Description, InterfaceType } from '../../subgraph/state.js';
|
|
3
4
|
import type { Key, MapByGraph, TypeBuilder } from './common.js';
|
|
4
5
|
export declare function interfaceTypeBuilder(): TypeBuilder<InterfaceType, InterfaceTypeState>;
|
|
5
6
|
export type InterfaceTypeState = {
|
|
7
|
+
kind: 'interface';
|
|
6
8
|
name: string;
|
|
7
9
|
tags: Set<string>;
|
|
8
10
|
inaccessible: boolean;
|
|
@@ -52,16 +54,19 @@ type InterfaceTypeInGraph = {
|
|
|
52
54
|
keys: Key[];
|
|
53
55
|
interfaces: Set<string>;
|
|
54
56
|
implementedBy: Set<string>;
|
|
57
|
+
version: FederationVersion;
|
|
55
58
|
};
|
|
56
59
|
type FieldStateInGraph = {
|
|
57
60
|
type: string;
|
|
58
61
|
override: string | null;
|
|
59
62
|
provides: string | null;
|
|
60
63
|
requires: string | null;
|
|
64
|
+
version: FederationVersion;
|
|
61
65
|
};
|
|
62
66
|
type ArgStateInGraph = {
|
|
63
67
|
type: string;
|
|
64
68
|
defaultValue?: string;
|
|
69
|
+
version: FederationVersion;
|
|
65
70
|
};
|
|
66
71
|
export {};
|
|
67
72
|
//# sourceMappingURL=interface-type.d.ts.map
|
|
@@ -5,6 +5,7 @@ import type { Key, MapByGraph, TypeBuilder } from './common.cjs';
|
|
|
5
5
|
export declare function isRealExtension(meta: ObjectTypeStateInGraph, version: FederationVersion): boolean;
|
|
6
6
|
export declare function objectTypeBuilder(): TypeBuilder<ObjectType, ObjectTypeState>;
|
|
7
7
|
export type ObjectTypeState = {
|
|
8
|
+
kind: 'object';
|
|
8
9
|
name: string;
|
|
9
10
|
tags: Set<string>;
|
|
10
11
|
inaccessible: boolean;
|
|
@@ -64,6 +65,7 @@ export type ObjectTypeStateInGraph = {
|
|
|
64
65
|
interfaces: Set<string>;
|
|
65
66
|
inaccessible: boolean;
|
|
66
67
|
shareable: boolean;
|
|
68
|
+
version: FederationVersion;
|
|
67
69
|
};
|
|
68
70
|
type FieldStateInGraph = {
|
|
69
71
|
type: string;
|
|
@@ -78,11 +80,14 @@ type FieldStateInGraph = {
|
|
|
78
80
|
required: boolean;
|
|
79
81
|
shareable: boolean;
|
|
80
82
|
usedAsKey: boolean;
|
|
83
|
+
extension: boolean;
|
|
84
|
+
version: FederationVersion;
|
|
81
85
|
};
|
|
82
86
|
type ArgStateInGraph = {
|
|
83
87
|
type: string;
|
|
84
88
|
inaccessible: boolean;
|
|
85
89
|
defaultValue?: string;
|
|
90
|
+
version: FederationVersion;
|
|
86
91
|
};
|
|
87
92
|
export {};
|
|
88
93
|
//# sourceMappingURL=object-type.d.ts.map
|
|
@@ -5,6 +5,7 @@ import type { Key, MapByGraph, TypeBuilder } from './common.js';
|
|
|
5
5
|
export declare function isRealExtension(meta: ObjectTypeStateInGraph, version: FederationVersion): boolean;
|
|
6
6
|
export declare function objectTypeBuilder(): TypeBuilder<ObjectType, ObjectTypeState>;
|
|
7
7
|
export type ObjectTypeState = {
|
|
8
|
+
kind: 'object';
|
|
8
9
|
name: string;
|
|
9
10
|
tags: Set<string>;
|
|
10
11
|
inaccessible: boolean;
|
|
@@ -64,6 +65,7 @@ export type ObjectTypeStateInGraph = {
|
|
|
64
65
|
interfaces: Set<string>;
|
|
65
66
|
inaccessible: boolean;
|
|
66
67
|
shareable: boolean;
|
|
68
|
+
version: FederationVersion;
|
|
67
69
|
};
|
|
68
70
|
type FieldStateInGraph = {
|
|
69
71
|
type: string;
|
|
@@ -78,11 +80,14 @@ type FieldStateInGraph = {
|
|
|
78
80
|
required: boolean;
|
|
79
81
|
shareable: boolean;
|
|
80
82
|
usedAsKey: boolean;
|
|
83
|
+
extension: boolean;
|
|
84
|
+
version: FederationVersion;
|
|
81
85
|
};
|
|
82
86
|
type ArgStateInGraph = {
|
|
83
87
|
type: string;
|
|
84
88
|
inaccessible: boolean;
|
|
85
89
|
defaultValue?: string;
|
|
90
|
+
version: FederationVersion;
|
|
86
91
|
};
|
|
87
92
|
export {};
|
|
88
93
|
//# sourceMappingURL=object-type.d.ts.map
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import { DirectiveNode } from 'graphql';
|
|
2
|
+
import { FederationVersion } from '../../specifications/federation.cjs';
|
|
2
3
|
import { Description, ScalarType } from '../../subgraph/state.cjs';
|
|
3
4
|
import { MapByGraph, TypeBuilder } from './common.cjs';
|
|
4
5
|
export declare function scalarTypeBuilder(): TypeBuilder<ScalarType, ScalarTypeState>;
|
|
5
6
|
export type ScalarTypeState = {
|
|
7
|
+
kind: 'scalar';
|
|
6
8
|
name: string;
|
|
7
9
|
tags: Set<string>;
|
|
8
10
|
inaccessible: boolean;
|
|
@@ -18,6 +20,7 @@ export type ScalarTypeState = {
|
|
|
18
20
|
};
|
|
19
21
|
type ScalarTypeStateInGraph = {
|
|
20
22
|
inaccessible: boolean;
|
|
23
|
+
version: FederationVersion;
|
|
21
24
|
};
|
|
22
25
|
export {};
|
|
23
26
|
//# sourceMappingURL=scalar-type.d.ts.map
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import { DirectiveNode } from 'graphql';
|
|
2
|
+
import { FederationVersion } from '../../specifications/federation.js';
|
|
2
3
|
import { Description, ScalarType } from '../../subgraph/state.js';
|
|
3
4
|
import { MapByGraph, TypeBuilder } from './common.js';
|
|
4
5
|
export declare function scalarTypeBuilder(): TypeBuilder<ScalarType, ScalarTypeState>;
|
|
5
6
|
export type ScalarTypeState = {
|
|
7
|
+
kind: 'scalar';
|
|
6
8
|
name: string;
|
|
7
9
|
tags: Set<string>;
|
|
8
10
|
inaccessible: boolean;
|
|
@@ -18,6 +20,7 @@ export type ScalarTypeState = {
|
|
|
18
20
|
};
|
|
19
21
|
type ScalarTypeStateInGraph = {
|
|
20
22
|
inaccessible: boolean;
|
|
23
|
+
version: FederationVersion;
|
|
21
24
|
};
|
|
22
25
|
export {};
|
|
23
26
|
//# sourceMappingURL=scalar-type.d.ts.map
|
|
@@ -1,7 +1,9 @@
|
|
|
1
|
+
import { FederationVersion } from '../../specifications/federation.cjs';
|
|
1
2
|
import { Description, UnionType } from '../../subgraph/state.cjs';
|
|
2
3
|
import type { MapByGraph, TypeBuilder } from './common.cjs';
|
|
3
4
|
export declare function unionTypeBuilder(): TypeBuilder<UnionType, UnionTypeState>;
|
|
4
5
|
export type UnionTypeState = {
|
|
6
|
+
kind: 'union';
|
|
5
7
|
name: string;
|
|
6
8
|
tags: Set<string>;
|
|
7
9
|
hasDefinition: boolean;
|
|
@@ -12,6 +14,7 @@ export type UnionTypeState = {
|
|
|
12
14
|
};
|
|
13
15
|
type UnionTypeInGraph = {
|
|
14
16
|
members: Set<string>;
|
|
17
|
+
version: FederationVersion;
|
|
15
18
|
};
|
|
16
19
|
export {};
|
|
17
20
|
//# sourceMappingURL=union-type.d.ts.map
|
|
@@ -1,7 +1,9 @@
|
|
|
1
|
+
import { FederationVersion } from '../../specifications/federation.js';
|
|
1
2
|
import { Description, UnionType } from '../../subgraph/state.js';
|
|
2
3
|
import type { MapByGraph, TypeBuilder } from './common.js';
|
|
3
4
|
export declare function unionTypeBuilder(): TypeBuilder<UnionType, UnionTypeState>;
|
|
4
5
|
export type UnionTypeState = {
|
|
6
|
+
kind: 'union';
|
|
5
7
|
name: string;
|
|
6
8
|
tags: Set<string>;
|
|
7
9
|
hasDefinition: boolean;
|
|
@@ -12,6 +14,7 @@ export type UnionTypeState = {
|
|
|
12
14
|
};
|
|
13
15
|
type UnionTypeInGraph = {
|
|
14
16
|
members: Set<string>;
|
|
17
|
+
version: FederationVersion;
|
|
15
18
|
};
|
|
16
19
|
export {};
|
|
17
20
|
//# sourceMappingURL=union-type.d.ts.map
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { DirectiveDefinitionNode, TypeDefinitionNode } from 'graphql';
|
|
2
2
|
import { Link } from '../specifications/link.cjs';
|
|
3
3
|
import { SubgraphState } from '../subgraph/state.cjs';
|
|
4
|
-
import { Graph } from './composition/common.cjs';
|
|
5
4
|
import { DirectiveState } from './composition/directive.cjs';
|
|
6
5
|
import { EnumTypeState } from './composition/enum-type.cjs';
|
|
7
6
|
import { InputObjectTypeState } from './composition/input-object-type.cjs';
|
|
@@ -10,7 +9,7 @@ import { ObjectTypeState } from './composition/object-type.cjs';
|
|
|
10
9
|
import { ScalarTypeState } from './composition/scalar-type.cjs';
|
|
11
10
|
import { UnionTypeState } from './composition/union-type.cjs';
|
|
12
11
|
export type SupergraphState = {
|
|
13
|
-
|
|
12
|
+
subgraphs: Map<string, SubgraphState>;
|
|
14
13
|
scalarTypes: Map<string, ScalarTypeState>;
|
|
15
14
|
objectTypes: Map<string, ObjectTypeState>;
|
|
16
15
|
interfaceTypes: Map<string, InterfaceTypeState>;
|
|
@@ -31,10 +30,11 @@ export type SupergraphState = {
|
|
|
31
30
|
};
|
|
32
31
|
export type SupergraphStateBuilder = ReturnType<typeof createSupergraphStateBuilder>;
|
|
33
32
|
export declare function createSupergraphStateBuilder(): {
|
|
34
|
-
|
|
35
|
-
getGraph(id: string):
|
|
33
|
+
addSubgraph(subgraph: SubgraphState): void;
|
|
34
|
+
getGraph(id: string): SubgraphState | undefined;
|
|
36
35
|
visitSubgraphState(subgraphState: SubgraphState): void;
|
|
37
36
|
getSupergraphState(): SupergraphState;
|
|
37
|
+
getSubgraphState(graphId: string): SubgraphState | undefined;
|
|
38
38
|
links(): readonly {
|
|
39
39
|
name: string | null;
|
|
40
40
|
version: string | null;
|