@theguild/federation-composition 0.10.0 → 0.10.1-alpha-20240313122455-e8bf68a
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/supergraph/validation/rules/satisfiablity/edge.js +6 -6
- package/cjs/supergraph/validation/rules/satisfiablity/fields.js +4 -4
- package/cjs/supergraph/validation/rules/satisfiablity/finder.js +12 -12
- package/cjs/supergraph/validation/rules/satisfiablity/graph.js +27 -27
- package/cjs/supergraph/validation/rules/satisfiablity/move-validator.js +17 -17
- package/cjs/supergraph/validation/rules/satisfiablity/moves.js +3 -3
- package/cjs/supergraph/validation/rules/satisfiablity/node.js +2 -2
- package/cjs/supergraph/validation/rules/satisfiablity/operation-path.js +4 -4
- package/cjs/supergraph/validation/rules/satisfiablity/supergraph.js +14 -14
- package/cjs/supergraph/validation/rules/satisfiablity/walker.js +13 -13
- package/esm/supergraph/validation/rules/satisfiablity/edge.js +2 -2
- package/esm/supergraph/validation/rules/satisfiablity/fields.js +2 -2
- package/esm/supergraph/validation/rules/satisfiablity/finder.js +2 -2
- package/esm/supergraph/validation/rules/satisfiablity/graph.js +6 -6
- package/esm/supergraph/validation/rules/satisfiablity/move-validator.js +3 -3
- package/esm/supergraph/validation/rules/satisfiablity/moves.js +1 -1
- package/esm/supergraph/validation/rules/satisfiablity/node.js +1 -1
- package/esm/supergraph/validation/rules/satisfiablity/operation-path.js +2 -2
- package/esm/supergraph/validation/rules/satisfiablity/supergraph.js +6 -6
- package/esm/supergraph/validation/rules/satisfiablity/walker.js +3 -3
- package/package.json +1 -1
- package/typings/supergraph/validation/rules/satisfiablity/edge.d.cts +3 -3
- package/typings/supergraph/validation/rules/satisfiablity/edge.d.ts +3 -3
- package/typings/supergraph/validation/rules/satisfiablity/fields.d.cts +1 -1
- package/typings/supergraph/validation/rules/satisfiablity/fields.d.ts +1 -1
- package/typings/supergraph/validation/rules/satisfiablity/finder.d.cts +7 -7
- package/typings/supergraph/validation/rules/satisfiablity/finder.d.ts +7 -7
- package/typings/supergraph/validation/rules/satisfiablity/graph.d.cts +10 -10
- package/typings/supergraph/validation/rules/satisfiablity/graph.d.ts +10 -10
- package/typings/supergraph/validation/rules/satisfiablity/move-validator.d.cts +6 -6
- package/typings/supergraph/validation/rules/satisfiablity/move-validator.d.ts +6 -6
- package/typings/supergraph/validation/rules/satisfiablity/moves.d.cts +1 -1
- package/typings/supergraph/validation/rules/satisfiablity/moves.d.ts +1 -1
- package/typings/supergraph/validation/rules/satisfiablity/node.d.cts +5 -5
- package/typings/supergraph/validation/rules/satisfiablity/node.d.ts +5 -5
- package/typings/supergraph/validation/rules/satisfiablity/operation-path.d.cts +2 -2
- package/typings/supergraph/validation/rules/satisfiablity/operation-path.d.ts +2 -2
- package/typings/supergraph/validation/rules/satisfiablity/supergraph.d.cts +4 -4
- package/typings/supergraph/validation/rules/satisfiablity/supergraph.d.ts +4 -4
- package/typings/supergraph/validation/rules/satisfiablity/walker.d.cts +6 -6
- package/typings/supergraph/validation/rules/satisfiablity/walker.d.ts +6 -6
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.Edge = exports.assertFieldEdge = exports.isFieldEdge = exports.assertAbstractEdge = exports.isAbstractEdge = exports.assertEntityEdge = exports.isEntityEdge = void 0;
|
|
4
|
-
const
|
|
5
|
-
const
|
|
4
|
+
const helpers_js_1 = require("./helpers.js");
|
|
5
|
+
const moves_js_1 = require("./moves.js");
|
|
6
6
|
function isEntityEdge(edge) {
|
|
7
|
-
return edge.move instanceof
|
|
7
|
+
return edge.move instanceof moves_js_1.EntityMove;
|
|
8
8
|
}
|
|
9
9
|
exports.isEntityEdge = isEntityEdge;
|
|
10
10
|
function assertEntityEdge(edge) {
|
|
@@ -14,7 +14,7 @@ function assertEntityEdge(edge) {
|
|
|
14
14
|
}
|
|
15
15
|
exports.assertEntityEdge = assertEntityEdge;
|
|
16
16
|
function isAbstractEdge(edge) {
|
|
17
|
-
return edge.move instanceof
|
|
17
|
+
return edge.move instanceof moves_js_1.AbstractMove;
|
|
18
18
|
}
|
|
19
19
|
exports.isAbstractEdge = isAbstractEdge;
|
|
20
20
|
function assertAbstractEdge(edge) {
|
|
@@ -24,7 +24,7 @@ function assertAbstractEdge(edge) {
|
|
|
24
24
|
}
|
|
25
25
|
exports.assertAbstractEdge = assertAbstractEdge;
|
|
26
26
|
function isFieldEdge(edge) {
|
|
27
|
-
return edge.move instanceof
|
|
27
|
+
return edge.move instanceof moves_js_1.FieldMove;
|
|
28
28
|
}
|
|
29
29
|
exports.isFieldEdge = isFieldEdge;
|
|
30
30
|
function assertFieldEdge(edge) {
|
|
@@ -38,7 +38,7 @@ class Edge {
|
|
|
38
38
|
move;
|
|
39
39
|
tail;
|
|
40
40
|
resolvable = [];
|
|
41
|
-
_toString = (0,
|
|
41
|
+
_toString = (0, helpers_js_1.lazy)(() => `${this.head} -(${this.move})-> ${this.tail}`);
|
|
42
42
|
constructor(head, move, tail) {
|
|
43
43
|
this.head = head;
|
|
44
44
|
this.move = move;
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.FieldsResolver = exports.Fields = void 0;
|
|
4
4
|
const graphql_1 = require("graphql");
|
|
5
|
-
const
|
|
6
|
-
const
|
|
5
|
+
const helpers_js_1 = require("../../../../subgraph/helpers.js");
|
|
6
|
+
const state_js_1 = require("../../../../utils/state.js");
|
|
7
7
|
class Fields {
|
|
8
8
|
typeName;
|
|
9
9
|
source;
|
|
@@ -68,7 +68,7 @@ class FieldsResolver {
|
|
|
68
68
|
if (!typeState) {
|
|
69
69
|
throw new Error(`Expected an object type when resolving keyFields of ${typeName}`);
|
|
70
70
|
}
|
|
71
|
-
const selectionSetNode = (0,
|
|
71
|
+
const selectionSetNode = (0, helpers_js_1.parseFields)(keyFields);
|
|
72
72
|
if (!selectionSetNode) {
|
|
73
73
|
throw new Error(`Expected a selection set when resolving keyFields of ${typeName}`);
|
|
74
74
|
}
|
|
@@ -92,7 +92,7 @@ class FieldsResolver {
|
|
|
92
92
|
throw new Error(`Type "${typeName.toString()}" does not have field "${fieldNode.name.value}".`);
|
|
93
93
|
}
|
|
94
94
|
if (fieldNode.selectionSet) {
|
|
95
|
-
const outputType = (0,
|
|
95
|
+
const outputType = (0, state_js_1.stripTypeModifiers)(typeState.fields.get(fieldNode.name.value).type);
|
|
96
96
|
fields.push({
|
|
97
97
|
fieldName: fieldNode.name.value,
|
|
98
98
|
typeName,
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.PathFinder = exports.concatIfNotExistsFields = exports.concatIfNotExistsString = void 0;
|
|
4
|
-
const
|
|
5
|
-
const
|
|
4
|
+
const edge_js_1 = require("./edge.js");
|
|
5
|
+
const errors_js_1 = require("./errors.js");
|
|
6
6
|
function concatIfNotExistsString(list, item) {
|
|
7
7
|
if (list.includes(item)) {
|
|
8
8
|
return list;
|
|
@@ -49,7 +49,7 @@ class PathFinder {
|
|
|
49
49
|
continue;
|
|
50
50
|
}
|
|
51
51
|
if (!isFieldTarget) {
|
|
52
|
-
if ((0,
|
|
52
|
+
if ((0, edge_js_1.isAbstractEdge)(edge) && edge.tail.typeName === typeName) {
|
|
53
53
|
this.logger.groupEnd(() => 'Resolvable: ' + edge);
|
|
54
54
|
const newPath = path.clone().move(edge);
|
|
55
55
|
nextPaths.push(newPath);
|
|
@@ -57,7 +57,7 @@ class PathFinder {
|
|
|
57
57
|
}
|
|
58
58
|
}
|
|
59
59
|
if (isFieldTarget &&
|
|
60
|
-
(0,
|
|
60
|
+
(0, edge_js_1.isFieldEdge)(edge) &&
|
|
61
61
|
edge.move.typeName === typeName &&
|
|
62
62
|
edge.move.fieldName === fieldName) {
|
|
63
63
|
const resolvable = this.moveValidator.isEdgeResolvable(edge, path, [], [], []);
|
|
@@ -77,12 +77,12 @@ class PathFinder {
|
|
|
77
77
|
if (nextPaths.length === 0) {
|
|
78
78
|
if (errors.length === 0) {
|
|
79
79
|
if (isFieldTarget) {
|
|
80
|
-
errors.push(
|
|
80
|
+
errors.push(errors_js_1.SatisfiabilityError.forMissingField(tail.graphName, typeName, fieldName));
|
|
81
81
|
const typeNodes = this.graph.nodesOf(typeName);
|
|
82
82
|
for (const typeNode of typeNodes) {
|
|
83
83
|
const edges = this.graph.fieldEdgesOfHead(typeNode, fieldName);
|
|
84
84
|
for (const edge of edges) {
|
|
85
|
-
if ((0,
|
|
85
|
+
if ((0, edge_js_1.isFieldEdge)(edge) &&
|
|
86
86
|
edge.move.typeName === typeName &&
|
|
87
87
|
edge.move.fieldName === fieldName &&
|
|
88
88
|
!this.moveValidator.isExternal(edge)) {
|
|
@@ -93,7 +93,7 @@ class PathFinder {
|
|
|
93
93
|
? typeStateInGraph.keys.filter(key => key.resolvable)
|
|
94
94
|
: [];
|
|
95
95
|
if (keys.length === 0) {
|
|
96
|
-
errors.push(
|
|
96
|
+
errors.push(errors_js_1.SatisfiabilityError.forNoKey(tail.graphName, edge.tail.graphName, typeName, fieldName));
|
|
97
97
|
}
|
|
98
98
|
}
|
|
99
99
|
}
|
|
@@ -160,11 +160,11 @@ class PathFinder {
|
|
|
160
160
|
this.logger.groupEnd(() => 'Ignore: already visited edge');
|
|
161
161
|
continue;
|
|
162
162
|
}
|
|
163
|
-
if (edge.tail.graphName === sourceGraphName && !(0,
|
|
163
|
+
if (edge.tail.graphName === sourceGraphName && !(0, edge_js_1.isAbstractEdge)(edge)) {
|
|
164
164
|
this.logger.groupEnd(() => 'Ignore: we are back to the same graph');
|
|
165
165
|
continue;
|
|
166
166
|
}
|
|
167
|
-
if (isFieldTarget && (0,
|
|
167
|
+
if (isFieldTarget && (0, edge_js_1.isEntityEdge)(edge)) {
|
|
168
168
|
if (visitedFields.some(f => f.equals(edge.move.keyFields))) {
|
|
169
169
|
this.logger.groupEnd(() => 'Ignore: already visited fields');
|
|
170
170
|
continue;
|
|
@@ -198,14 +198,14 @@ class PathFinder {
|
|
|
198
198
|
this.logger.log(() => 'Did not find direct paths');
|
|
199
199
|
this.logger.groupEnd(() => 'Adding to queue: ' + newPath);
|
|
200
200
|
}
|
|
201
|
-
else if (isFieldTarget && (0,
|
|
201
|
+
else if (isFieldTarget && (0, edge_js_1.isFieldEdge)(edge)) {
|
|
202
202
|
this.logger.log(() => 'Cross graph field move:' + edge.move);
|
|
203
203
|
if (path.isVisitedEdge(edge)) {
|
|
204
204
|
this.logger.groupEnd(() => 'Already visited');
|
|
205
205
|
continue;
|
|
206
206
|
}
|
|
207
207
|
if (isFieldTarget && edge.move.requires?.contains(typeName, fieldName)) {
|
|
208
|
-
errors.push(
|
|
208
|
+
errors.push(errors_js_1.SatisfiabilityError.forRequire(tail.graphName, typeName, fieldName));
|
|
209
209
|
this.logger.groupEnd(() => 'Ignored');
|
|
210
210
|
continue;
|
|
211
211
|
}
|
|
@@ -224,7 +224,7 @@ class PathFinder {
|
|
|
224
224
|
setShortest(path.clone().move(edge), shortestPathPerGraph);
|
|
225
225
|
this.logger.groupEnd(() => 'Resolvable: ' + edge);
|
|
226
226
|
}
|
|
227
|
-
else if (!isFieldTarget && (0,
|
|
227
|
+
else if (!isFieldTarget && (0, edge_js_1.isAbstractEdge)(edge)) {
|
|
228
228
|
if (shortestPathPerGraph.has(edge.tail.graphName)) {
|
|
229
229
|
this.logger.groupEnd(() => 'Already found a shorter path to ' + edge.tail);
|
|
230
230
|
continue;
|
|
@@ -2,12 +2,12 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.Graph = void 0;
|
|
4
4
|
const graphql_1 = require("graphql");
|
|
5
|
-
const
|
|
6
|
-
const
|
|
7
|
-
const
|
|
8
|
-
const
|
|
9
|
-
const
|
|
10
|
-
const
|
|
5
|
+
const state_js_1 = require("../../../../utils/state.js");
|
|
6
|
+
const constants_js_1 = require("./constants.js");
|
|
7
|
+
const edge_js_1 = require("./edge.js");
|
|
8
|
+
const helpers_js_1 = require("./helpers.js");
|
|
9
|
+
const moves_js_1 = require("./moves.js");
|
|
10
|
+
const node_js_1 = require("./node.js");
|
|
11
11
|
class Graph {
|
|
12
12
|
name;
|
|
13
13
|
supergraphState;
|
|
@@ -38,7 +38,7 @@ class Graph {
|
|
|
38
38
|
else {
|
|
39
39
|
this.idSymbol = id;
|
|
40
40
|
this.id = id.toString();
|
|
41
|
-
this.isSubgraph = this.idSymbol !==
|
|
41
|
+
this.isSubgraph = this.idSymbol !== constants_js_1.SUPERGRAPH_ID;
|
|
42
42
|
}
|
|
43
43
|
}
|
|
44
44
|
addUnreachableTypes() {
|
|
@@ -113,7 +113,7 @@ class Graph {
|
|
|
113
113
|
continue;
|
|
114
114
|
}
|
|
115
115
|
for (const edge of edges) {
|
|
116
|
-
edgesToAdd.push(new
|
|
116
|
+
edgesToAdd.push(new edge_js_1.Edge(edge.head, edge.move, tailNode));
|
|
117
117
|
}
|
|
118
118
|
}
|
|
119
119
|
}
|
|
@@ -132,10 +132,10 @@ class Graph {
|
|
|
132
132
|
const typeStateInGraph = tailNode.typeState.byGraph.get(tailNode.graphId);
|
|
133
133
|
const keys = (typeStateInGraph?.keys ?? [])
|
|
134
134
|
.slice()
|
|
135
|
-
.sort((a, b) => (0,
|
|
135
|
+
.sort((a, b) => (0, helpers_js_1.scoreKeyFields)(a.fields) - (0, helpers_js_1.scoreKeyFields)(b.fields));
|
|
136
136
|
for (const key of keys) {
|
|
137
137
|
if (key.resolvable) {
|
|
138
|
-
edgesToAdd.push(new
|
|
138
|
+
edgesToAdd.push(new edge_js_1.Edge(headNode, new moves_js_1.EntityMove(this.fieldsResolver.resolve(headNode.typeName, key.fields)), tailNode));
|
|
139
139
|
}
|
|
140
140
|
}
|
|
141
141
|
}
|
|
@@ -181,7 +181,7 @@ class Graph {
|
|
|
181
181
|
throw new Error(`Expected an abstract edge matching "${typeName}" to be defined`);
|
|
182
182
|
}
|
|
183
183
|
const newTail = this.duplicateNode(edge.tail);
|
|
184
|
-
const newEdge = new
|
|
184
|
+
const newEdge = new edge_js_1.Edge(edge.head, edge.move, newTail);
|
|
185
185
|
this.replaceEdgeAt(edge.head.index, edge.tail.index, newEdge, edgeIndex);
|
|
186
186
|
queue.push({
|
|
187
187
|
head: newTail,
|
|
@@ -196,12 +196,12 @@ class Graph {
|
|
|
196
196
|
if (!edge) {
|
|
197
197
|
throw new Error('Expected edge to be defined');
|
|
198
198
|
}
|
|
199
|
-
(0,
|
|
199
|
+
(0, edge_js_1.assertAbstractEdge)(edge);
|
|
200
200
|
if (edge.isCrossGraphEdge()) {
|
|
201
201
|
continue;
|
|
202
202
|
}
|
|
203
203
|
const newTail = this.duplicateNode(edge.tail);
|
|
204
|
-
const newEdge = new
|
|
204
|
+
const newEdge = new edge_js_1.Edge(edge.head, new moves_js_1.AbstractMove(), newTail);
|
|
205
205
|
this.replaceEdgeAt(edge.head.index, edge.tail.index, newEdge, index);
|
|
206
206
|
queue.push({
|
|
207
207
|
head: newTail,
|
|
@@ -233,12 +233,12 @@ class Graph {
|
|
|
233
233
|
if (!edge) {
|
|
234
234
|
throw new Error('Expected edge to be defined');
|
|
235
235
|
}
|
|
236
|
-
(0,
|
|
236
|
+
(0, edge_js_1.assertFieldEdge)(edge);
|
|
237
237
|
if (edge.isCrossGraphEdge()) {
|
|
238
238
|
continue;
|
|
239
239
|
}
|
|
240
240
|
const newTail = this.duplicateNode(edge.tail);
|
|
241
|
-
const newEdge = new
|
|
241
|
+
const newEdge = new edge_js_1.Edge(edge.head, new moves_js_1.FieldMove(edge.move.typeName, edge.move.fieldName, edge.move.requires, edge.move.provides, true), newTail);
|
|
242
242
|
this.replaceEdgeAt(edge.head.index, edge.tail.index, newEdge, index);
|
|
243
243
|
if (providedField.selectionSet) {
|
|
244
244
|
queue.push({
|
|
@@ -280,11 +280,11 @@ class Graph {
|
|
|
280
280
|
if (edge.isCrossGraphEdge()) {
|
|
281
281
|
continue;
|
|
282
282
|
}
|
|
283
|
-
if (!((0,
|
|
283
|
+
if (!((0, edge_js_1.isFieldEdge)(edge) && edge.move.provides)) {
|
|
284
284
|
continue;
|
|
285
285
|
}
|
|
286
286
|
const newTail = this.duplicateNode(edge.tail);
|
|
287
|
-
const newEdge = new
|
|
287
|
+
const newEdge = new edge_js_1.Edge(edge.head, edge.move, newTail);
|
|
288
288
|
this.replaceEdgeAt(headIndex, edge.tail.index, newEdge, edgeIndex);
|
|
289
289
|
const queue = [
|
|
290
290
|
{
|
|
@@ -313,7 +313,7 @@ class Graph {
|
|
|
313
313
|
duplicateNode(originalNode) {
|
|
314
314
|
const newNode = this.createNode(originalNode.typeName, originalNode.typeState, originalNode.graphId, originalNode.graphName);
|
|
315
315
|
for (const edge of this.edgesOfHead(originalNode)) {
|
|
316
|
-
this.addEdge(new
|
|
316
|
+
this.addEdge(new edge_js_1.Edge(newNode, edge.move, edge.tail));
|
|
317
317
|
}
|
|
318
318
|
return newNode;
|
|
319
319
|
}
|
|
@@ -557,7 +557,7 @@ class Graph {
|
|
|
557
557
|
if (members) {
|
|
558
558
|
for (const memberTypeName of members) {
|
|
559
559
|
const tail = this.createNodesAndEdgesForType(memberTypeName);
|
|
560
|
-
this.addEdge(new
|
|
560
|
+
this.addEdge(new edge_js_1.Edge(head, new moves_js_1.AbstractMove(), tail));
|
|
561
561
|
}
|
|
562
562
|
}
|
|
563
563
|
return head;
|
|
@@ -574,7 +574,7 @@ class Graph {
|
|
|
574
574
|
if (implementedBy) {
|
|
575
575
|
for (const memberTypeName of implementedBy) {
|
|
576
576
|
const tail = this.createNodesAndEdgesForType(memberTypeName);
|
|
577
|
-
this.addEdge(new
|
|
577
|
+
this.addEdge(new edge_js_1.Edge(head, new moves_js_1.AbstractMove(), tail));
|
|
578
578
|
}
|
|
579
579
|
}
|
|
580
580
|
return head;
|
|
@@ -591,17 +591,17 @@ class Graph {
|
|
|
591
591
|
return;
|
|
592
592
|
}
|
|
593
593
|
}
|
|
594
|
-
const outputTypeName = (0,
|
|
594
|
+
const outputTypeName = (0, state_js_1.stripTypeModifiers)(field.type);
|
|
595
595
|
const tail = this.createNodesAndEdgesForType(outputTypeName);
|
|
596
596
|
if (!tail) {
|
|
597
597
|
throw new Error(`Failed to create Node for ${outputTypeName} in subgraph ${this.id}`);
|
|
598
598
|
}
|
|
599
599
|
if (this.isSupergraph()) {
|
|
600
|
-
return this.addEdge(new
|
|
600
|
+
return this.addEdge(new edge_js_1.Edge(head, new moves_js_1.FieldMove(head.typeName, field.name), tail));
|
|
601
601
|
}
|
|
602
602
|
const requires = field.byGraph.get(head.graphId)?.requires;
|
|
603
603
|
const provides = field.byGraph.get(head.graphId)?.provides;
|
|
604
|
-
return this.addEdge(new
|
|
604
|
+
return this.addEdge(new edge_js_1.Edge(head, new moves_js_1.FieldMove(head.typeName, field.name, requires ? this.fieldsResolver.resolve(head.typeName, requires) : null, provides ? this.fieldsResolver.resolve(outputTypeName, provides) : null), tail));
|
|
605
605
|
}
|
|
606
606
|
createTypeNode(typeName, typeState) {
|
|
607
607
|
if (this.typeNameToNodeIndexes.has(typeName)) {
|
|
@@ -611,7 +611,7 @@ class Graph {
|
|
|
611
611
|
}
|
|
612
612
|
createNode(typeName, typeState, graphId, graphName) {
|
|
613
613
|
const index = this.nodesByTypeIndex.push([]) - 1;
|
|
614
|
-
const node = new
|
|
614
|
+
const node = new node_js_1.Node(index, typeName, typeState, graphId, graphName);
|
|
615
615
|
this.nodesByTypeIndex[node.index].push(node);
|
|
616
616
|
this.edgesByHeadTypeIndex.push([]);
|
|
617
617
|
this.edgesByTailTypeIndex.push([]);
|
|
@@ -645,13 +645,13 @@ class Graph {
|
|
|
645
645
|
const edgeIndex = this.edgesByHeadTypeIndex[edge.head.index].push(edge) - 1;
|
|
646
646
|
this.edgesByTailTypeIndex[edge.tail.index].push(edge);
|
|
647
647
|
this.typeChildren[edge.head.index].add(edge.tail.typeName);
|
|
648
|
-
if ((0,
|
|
648
|
+
if ((0, edge_js_1.isFieldEdge)(edge)) {
|
|
649
649
|
edge.head.addFieldEdge(edge.move.fieldName, edgeIndex);
|
|
650
650
|
}
|
|
651
|
-
else if ((0,
|
|
651
|
+
else if ((0, edge_js_1.isEntityEdge)(edge)) {
|
|
652
652
|
edge.head.addEntityEdge(edge.head.typeName, edgeIndex);
|
|
653
653
|
}
|
|
654
|
-
else if ((0,
|
|
654
|
+
else if ((0, edge_js_1.isAbstractEdge)(edge)) {
|
|
655
655
|
edge.head.addAbstractEdge(edge.head.typeName, edgeIndex);
|
|
656
656
|
}
|
|
657
657
|
if (edge.isCrossGraphEdge()) {
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.MoveValidator = void 0;
|
|
4
|
-
const
|
|
5
|
-
const
|
|
6
|
-
const
|
|
4
|
+
const edge_js_1 = require("./edge.js");
|
|
5
|
+
const errors_js_1 = require("./errors.js");
|
|
6
|
+
const finder_js_1 = require("./finder.js");
|
|
7
7
|
class MoveValidator {
|
|
8
8
|
supergraph;
|
|
9
9
|
cache = new Map();
|
|
@@ -12,7 +12,7 @@ class MoveValidator {
|
|
|
12
12
|
constructor(logger, supergraph) {
|
|
13
13
|
this.supergraph = supergraph;
|
|
14
14
|
this.logger = logger.create('MoveValidator');
|
|
15
|
-
this.pathFinder = new
|
|
15
|
+
this.pathFinder = new finder_js_1.PathFinder(this.logger, supergraph, this);
|
|
16
16
|
}
|
|
17
17
|
canResolveFields(fields, path, visitedEdges, visitedGraphs, visitedFields) {
|
|
18
18
|
const cacheKey = JSON.stringify(fields) +
|
|
@@ -201,7 +201,7 @@ class MoveValidator {
|
|
|
201
201
|
};
|
|
202
202
|
}
|
|
203
203
|
isExternal(edge) {
|
|
204
|
-
if (!(0,
|
|
204
|
+
if (!(0, edge_js_1.isFieldEdge)(edge)) {
|
|
205
205
|
return false;
|
|
206
206
|
}
|
|
207
207
|
if (edge.move.provided) {
|
|
@@ -261,7 +261,7 @@ class MoveValidator {
|
|
|
261
261
|
return true;
|
|
262
262
|
}
|
|
263
263
|
isOverridden(edge) {
|
|
264
|
-
if (!(0,
|
|
264
|
+
if (!(0, edge_js_1.isFieldEdge)(edge)) {
|
|
265
265
|
return false;
|
|
266
266
|
}
|
|
267
267
|
if (!edge.head.typeState) {
|
|
@@ -286,22 +286,22 @@ class MoveValidator {
|
|
|
286
286
|
isEdgeResolvable(edge, path, visitedEdges, visitedGraphs, visitedFields) {
|
|
287
287
|
this.logger.group(() => 'Checking resolvability of ' + edge);
|
|
288
288
|
this.logger.log(() => 'Visited graphs: ' + visitedGraphs.join(','));
|
|
289
|
-
const resolvability = edge.getResolvability((0,
|
|
289
|
+
const resolvability = edge.getResolvability((0, finder_js_1.concatIfNotExistsString)(visitedGraphs, edge.tail.graphName));
|
|
290
290
|
if (resolvability) {
|
|
291
291
|
this.logger.groupEnd(() => resolvability.success
|
|
292
292
|
? `Can move to ${edge}`
|
|
293
293
|
: `Cannot move to ${edge} (already visited: ${resolvability.error.kind})`);
|
|
294
294
|
return resolvability;
|
|
295
295
|
}
|
|
296
|
-
if ((0,
|
|
296
|
+
if ((0, edge_js_1.isFieldEdge)(edge)) {
|
|
297
297
|
if (this.isOverridden(edge)) {
|
|
298
298
|
this.logger.groupEnd(() => 'Cannot move to ' + edge + ' because it is overridden');
|
|
299
|
-
return edge.setResolvable(false, visitedGraphs,
|
|
299
|
+
return edge.setResolvable(false, visitedGraphs, errors_js_1.SatisfiabilityError.forMissingField(edge.tail.graphName, edge.move.typeName, edge.move.fieldName));
|
|
300
300
|
}
|
|
301
301
|
if (edge.move.requires) {
|
|
302
302
|
this.logger.log(() => 'Detected @requires');
|
|
303
|
-
const newVisitedGraphs = (0,
|
|
304
|
-
const newVisitedFields = (0,
|
|
303
|
+
const newVisitedGraphs = (0, finder_js_1.concatIfNotExistsString)(visitedGraphs, edge.tail.graphName);
|
|
304
|
+
const newVisitedFields = (0, finder_js_1.concatIfNotExistsFields)(visitedFields, edge.move.requires);
|
|
305
305
|
this.logger.log(() => 'Visited graphs: ' + newVisitedGraphs.join(','));
|
|
306
306
|
if (this.canResolveFields(edge.move.requires.fields, path, visitedEdges.concat(edge), newVisitedGraphs, newVisitedFields).success) {
|
|
307
307
|
this.logger.groupEnd(() => 'Can move to ' + edge);
|
|
@@ -310,25 +310,25 @@ class MoveValidator {
|
|
|
310
310
|
this.logger.groupEnd(() => 'Cannot move to ' + edge + ' because @require is not resolvable');
|
|
311
311
|
return {
|
|
312
312
|
success: false,
|
|
313
|
-
error:
|
|
313
|
+
error: errors_js_1.SatisfiabilityError.forRequire(edge.head.graphName, edge.move.typeName, edge.move.fieldName),
|
|
314
314
|
};
|
|
315
315
|
}
|
|
316
316
|
else if (this.isExternal(edge)) {
|
|
317
317
|
this.logger.groupEnd(() => 'Cannot move to ' + edge + ' because it is external and cross-graph');
|
|
318
|
-
return edge.setResolvable(false, visitedGraphs,
|
|
318
|
+
return edge.setResolvable(false, visitedGraphs, errors_js_1.SatisfiabilityError.forExternal(edge.head.graphName, edge.move.typeName, edge.move.fieldName));
|
|
319
319
|
}
|
|
320
320
|
}
|
|
321
|
-
else if ((0,
|
|
321
|
+
else if ((0, edge_js_1.isEntityEdge)(edge)) {
|
|
322
322
|
this.logger.log(() => 'Detected @key');
|
|
323
|
-
const newVisitedGraphs = (0,
|
|
324
|
-
const newVisitedFields = (0,
|
|
323
|
+
const newVisitedGraphs = (0, finder_js_1.concatIfNotExistsString)(visitedGraphs, edge.tail.graphName);
|
|
324
|
+
const newVisitedFields = (0, finder_js_1.concatIfNotExistsFields)(visitedFields, edge.move.keyFields);
|
|
325
325
|
this.logger.log(() => 'Visited graphs: ' + newVisitedGraphs.join(','));
|
|
326
326
|
if (this.canResolveFields(edge.move.keyFields.fields, path, visitedEdges.concat(edge), newVisitedGraphs, newVisitedFields).success) {
|
|
327
327
|
this.logger.groupEnd(() => 'Can move to ' + edge);
|
|
328
328
|
return edge.setResolvable(true, newVisitedGraphs);
|
|
329
329
|
}
|
|
330
330
|
this.logger.groupEnd(() => 'Cannot move to ' + edge + ' because key fields are not resolvable');
|
|
331
|
-
return edge.setResolvable(false, newVisitedGraphs,
|
|
331
|
+
return edge.setResolvable(false, newVisitedGraphs, errors_js_1.SatisfiabilityError.forKey(edge.head.graphName, edge.tail.graphName, edge.head.typeName, edge.move.keyFields.toString()));
|
|
332
332
|
}
|
|
333
333
|
this.logger.groupEnd(() => 'Can move to ' + edge);
|
|
334
334
|
return edge.setResolvable(true, visitedGraphs);
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.EntityMove = exports.AbstractMove = exports.FieldMove = void 0;
|
|
4
|
-
const
|
|
4
|
+
const helpers_js_1 = require("./helpers.js");
|
|
5
5
|
class FieldMove {
|
|
6
6
|
typeName;
|
|
7
7
|
fieldName;
|
|
8
8
|
requires;
|
|
9
9
|
provides;
|
|
10
10
|
provided;
|
|
11
|
-
_toString = (0,
|
|
11
|
+
_toString = (0, helpers_js_1.lazy)(() => {
|
|
12
12
|
let str = this.fieldName;
|
|
13
13
|
if (this.requires) {
|
|
14
14
|
str += ` @require(${this.requires})`;
|
|
@@ -41,7 +41,7 @@ class AbstractMove {
|
|
|
41
41
|
exports.AbstractMove = AbstractMove;
|
|
42
42
|
class EntityMove {
|
|
43
43
|
keyFields;
|
|
44
|
-
_toString = (0,
|
|
44
|
+
_toString = (0, helpers_js_1.lazy)(() => `🔑 ${this.keyFields}`);
|
|
45
45
|
constructor(keyFields) {
|
|
46
46
|
this.keyFields = keyFields;
|
|
47
47
|
}
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.Node = void 0;
|
|
4
|
-
const
|
|
4
|
+
const helpers_js_1 = require("./helpers.js");
|
|
5
5
|
class Node {
|
|
6
6
|
index;
|
|
7
7
|
typeName;
|
|
8
8
|
typeState;
|
|
9
9
|
graphId;
|
|
10
10
|
graphName;
|
|
11
|
-
_toString = (0,
|
|
11
|
+
_toString = (0, helpers_js_1.lazy)(() => `${this.typeName}/${this.graphName}`);
|
|
12
12
|
isLeaf = false;
|
|
13
13
|
childrenIndex = new Map();
|
|
14
14
|
visitedGraphCombos = [];
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.OperationPath = void 0;
|
|
4
|
-
const
|
|
5
|
-
const
|
|
4
|
+
const edge_js_1 = require("./edge.js");
|
|
5
|
+
const helpers_js_1 = require("./helpers.js");
|
|
6
6
|
class OperationPath {
|
|
7
7
|
_rootNode;
|
|
8
|
-
_toString = (0,
|
|
8
|
+
_toString = (0, helpers_js_1.lazy)(() => {
|
|
9
9
|
let str = this._rootNode.toString();
|
|
10
10
|
for (let i = 0; i < this.previousEdges.length; i++) {
|
|
11
11
|
const edge = this.previousEdges[i];
|
|
@@ -57,7 +57,7 @@ class OperationPath {
|
|
|
57
57
|
advance(edge) {
|
|
58
58
|
this.previousEdges.push(edge);
|
|
59
59
|
this.previousNodes.push(edge.head);
|
|
60
|
-
this.previousSteps.push((0,
|
|
60
|
+
this.previousSteps.push((0, edge_js_1.isFieldEdge)(edge)
|
|
61
61
|
? {
|
|
62
62
|
typeName: edge.move.typeName,
|
|
63
63
|
fieldName: edge.move.fieldName,
|
|
@@ -1,37 +1,37 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.Supergraph = void 0;
|
|
4
|
-
const
|
|
5
|
-
const
|
|
6
|
-
const
|
|
7
|
-
const
|
|
8
|
-
const
|
|
9
|
-
const
|
|
4
|
+
const logger_js_1 = require("../../../../utils/logger.js");
|
|
5
|
+
const constants_js_1 = require("./constants.js");
|
|
6
|
+
const fields_js_1 = require("./fields.js");
|
|
7
|
+
const graph_js_1 = require("./graph.js");
|
|
8
|
+
const move_validator_js_1 = require("./move-validator.js");
|
|
9
|
+
const walker_js_1 = require("./walker.js");
|
|
10
10
|
class Supergraph {
|
|
11
11
|
supergraph;
|
|
12
12
|
mergedGraph;
|
|
13
13
|
fieldsResolver;
|
|
14
14
|
moveRequirementChecker;
|
|
15
|
-
logger = new
|
|
15
|
+
logger = new logger_js_1.Logger('Supergraph', new logger_js_1.LoggerContext());
|
|
16
16
|
constructor(supergraphState) {
|
|
17
|
-
this.fieldsResolver = new
|
|
18
|
-
this.supergraph = new
|
|
19
|
-
this.mergedGraph = new
|
|
17
|
+
this.fieldsResolver = new fields_js_1.FieldsResolver(supergraphState);
|
|
18
|
+
this.supergraph = new graph_js_1.Graph(this.logger, constants_js_1.SUPERGRAPH_ID, 'supergraph', supergraphState, this.fieldsResolver, true);
|
|
19
|
+
this.mergedGraph = new graph_js_1.Graph(this.logger, constants_js_1.SUPERGRAPH_ID, 'merged', supergraphState, this.fieldsResolver);
|
|
20
20
|
for (const [id, subgraphState] of supergraphState.subgraphs) {
|
|
21
|
-
this.mergedGraph.addSubgraph(new
|
|
21
|
+
this.mergedGraph.addSubgraph(new graph_js_1.Graph(this.logger, id, subgraphState.graph.name, supergraphState, this.fieldsResolver, false)
|
|
22
22
|
.addFromRoots()
|
|
23
23
|
.addFromEntities()
|
|
24
24
|
.addUnreachableTypes());
|
|
25
25
|
}
|
|
26
26
|
this.mergedGraph.joinSubgraphs();
|
|
27
27
|
this.supergraph.addFromRoots();
|
|
28
|
-
this.moveRequirementChecker = new
|
|
28
|
+
this.moveRequirementChecker = new move_validator_js_1.MoveValidator(this.logger, this.mergedGraph);
|
|
29
29
|
}
|
|
30
30
|
validate() {
|
|
31
|
-
return new
|
|
31
|
+
return new walker_js_1.Walker(this.logger, this.moveRequirementChecker, this.supergraph, this.mergedGraph).walk('dfs');
|
|
32
32
|
}
|
|
33
33
|
validateOperation(operation, steps) {
|
|
34
|
-
return new
|
|
34
|
+
return new walker_js_1.Walker(this.logger, this.moveRequirementChecker, this.supergraph, this.mergedGraph).walkTrail(operation, steps);
|
|
35
35
|
}
|
|
36
36
|
}
|
|
37
37
|
exports.Supergraph = Supergraph;
|
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.Walker = exports.WalkTracker = void 0;
|
|
4
4
|
const graphql_1 = require("graphql");
|
|
5
|
-
const
|
|
6
|
-
const
|
|
7
|
-
const
|
|
5
|
+
const edge_js_1 = require("./edge.js");
|
|
6
|
+
const finder_js_1 = require("./finder.js");
|
|
7
|
+
const operation_path_js_1 = require("./operation-path.js");
|
|
8
8
|
class WalkTracker {
|
|
9
9
|
superPath;
|
|
10
10
|
paths;
|
|
@@ -14,7 +14,7 @@ class WalkTracker {
|
|
|
14
14
|
this.paths = paths;
|
|
15
15
|
}
|
|
16
16
|
move(edge) {
|
|
17
|
-
if ((0,
|
|
17
|
+
if ((0, edge_js_1.isFieldEdge)(edge) || (0, edge_js_1.isAbstractEdge)(edge)) {
|
|
18
18
|
return new WalkTracker(this.superPath.clone().move(edge), []);
|
|
19
19
|
}
|
|
20
20
|
throw new Error('Expected edge to be FieldMove or AbstractMove');
|
|
@@ -31,7 +31,7 @@ class WalkTracker {
|
|
|
31
31
|
}
|
|
32
32
|
givesEmptyResult() {
|
|
33
33
|
const lastEdge = this.superPath.edge();
|
|
34
|
-
return (this.paths.length === 0 && this.errors.length === 0 && !!lastEdge && (0,
|
|
34
|
+
return (this.paths.length === 0 && this.errors.length === 0 && !!lastEdge && (0, edge_js_1.isAbstractEdge)(lastEdge));
|
|
35
35
|
}
|
|
36
36
|
isEdgeVisited(edge) {
|
|
37
37
|
return this.superPath.isVisitedEdge(edge);
|
|
@@ -65,7 +65,7 @@ class Walker {
|
|
|
65
65
|
this.supergraph = supergraph;
|
|
66
66
|
this.mergedGraph = mergedGraph;
|
|
67
67
|
this.logger = logger.create('Walker');
|
|
68
|
-
this.pathFinder = new
|
|
68
|
+
this.pathFinder = new finder_js_1.PathFinder(this.logger, this.mergedGraph, this.moveChecker);
|
|
69
69
|
}
|
|
70
70
|
walkTrail(operationType, steps) {
|
|
71
71
|
if (steps.length === 0) {
|
|
@@ -79,7 +79,7 @@ class Walker {
|
|
|
79
79
|
if (!rootNode) {
|
|
80
80
|
throw new Error(`Expected root node for operation type ${operationType}`);
|
|
81
81
|
}
|
|
82
|
-
let state = new WalkTracker(new
|
|
82
|
+
let state = new WalkTracker(new operation_path_js_1.OperationPath(rootNode), this.mergedGraph.nodesOf(rootNode.typeName, false).map(n => new operation_path_js_1.OperationPath(n)));
|
|
83
83
|
for (const step of steps) {
|
|
84
84
|
const stepId = 'fieldName' in step && step.fieldName
|
|
85
85
|
? `${step.typeName}.${step.fieldName}`
|
|
@@ -87,7 +87,7 @@ class Walker {
|
|
|
87
87
|
const isFieldStep = 'fieldName' in step;
|
|
88
88
|
const isEdgeIgnored = (edge) => {
|
|
89
89
|
if (isFieldStep) {
|
|
90
|
-
return !(0,
|
|
90
|
+
return !(0, edge_js_1.isFieldEdge)(edge) || edge.move.fieldName !== step.fieldName;
|
|
91
91
|
}
|
|
92
92
|
return true;
|
|
93
93
|
};
|
|
@@ -142,7 +142,7 @@ class Walker {
|
|
|
142
142
|
const edge = p.edge();
|
|
143
143
|
const tail = p.tail() ?? p.rootNode();
|
|
144
144
|
const tailGraphName = tail.graphName;
|
|
145
|
-
if (edge && (0,
|
|
145
|
+
if (edge && (0, edge_js_1.isFieldEdge)(edge) && edge.move.provides) {
|
|
146
146
|
return `${tailGraphName}#provides`;
|
|
147
147
|
}
|
|
148
148
|
return tailGraphName;
|
|
@@ -162,12 +162,12 @@ class Walker {
|
|
|
162
162
|
this.logger.groupEnd(() => 'Edge already visited: ' + superEdge);
|
|
163
163
|
continue;
|
|
164
164
|
}
|
|
165
|
-
if (!((0,
|
|
165
|
+
if (!((0, edge_js_1.isFieldEdge)(superEdge) || (0, edge_js_1.isAbstractEdge)(superEdge))) {
|
|
166
166
|
throw new Error('Expected edge to have a FieldMove or AbstractMove');
|
|
167
167
|
}
|
|
168
168
|
const nextState = state.move(superEdge);
|
|
169
169
|
const shortestPathPerTail = new Map();
|
|
170
|
-
const isFieldMove = (0,
|
|
170
|
+
const isFieldMove = (0, edge_js_1.isFieldEdge)(superEdge);
|
|
171
171
|
const id = isFieldMove
|
|
172
172
|
? `${superEdge.move.typeName}.${superEdge.move.fieldName}`
|
|
173
173
|
: `... on ${superEdge.tail.typeName}`;
|
|
@@ -215,7 +215,7 @@ class Walker {
|
|
|
215
215
|
.map(name => this.supergraph.nodeOf(name, false))
|
|
216
216
|
.filter((node) => !!node);
|
|
217
217
|
for (const rootNode of rootNodes) {
|
|
218
|
-
this._dfs(rootNode, new WalkTracker(new
|
|
218
|
+
this._dfs(rootNode, new WalkTracker(new operation_path_js_1.OperationPath(rootNode), this.mergedGraph.nodesOf(rootNode.typeName, false).map(n => new operation_path_js_1.OperationPath(n))), unreachable);
|
|
219
219
|
}
|
|
220
220
|
return unreachable;
|
|
221
221
|
}
|
|
@@ -255,7 +255,7 @@ class Walker {
|
|
|
255
255
|
.map(name => this.supergraph.nodeOf(name, false))
|
|
256
256
|
.filter((node) => !!node);
|
|
257
257
|
for (const rootNode of rootNodes) {
|
|
258
|
-
queue.push(new WalkTracker(new
|
|
258
|
+
queue.push(new WalkTracker(new operation_path_js_1.OperationPath(rootNode), this.mergedGraph.nodesOf(rootNode.typeName, false).map(n => new operation_path_js_1.OperationPath(n))));
|
|
259
259
|
}
|
|
260
260
|
while (queue.length > 0) {
|
|
261
261
|
const state = queue.pop();
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { lazy } from './helpers';
|
|
2
|
-
import { AbstractMove, EntityMove, FieldMove } from './moves';
|
|
1
|
+
import { lazy } from './helpers.js';
|
|
2
|
+
import { AbstractMove, EntityMove, FieldMove } from './moves.js';
|
|
3
3
|
export function isEntityEdge(edge) {
|
|
4
4
|
return edge.move instanceof EntityMove;
|
|
5
5
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Kind } from 'graphql';
|
|
2
|
-
import { parseFields } from '../../../../subgraph/helpers';
|
|
3
|
-
import { stripTypeModifiers } from '../../../../utils/state';
|
|
2
|
+
import { parseFields } from '../../../../subgraph/helpers.js';
|
|
3
|
+
import { stripTypeModifiers } from '../../../../utils/state.js';
|
|
4
4
|
export class Fields {
|
|
5
5
|
typeName;
|
|
6
6
|
source;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { isAbstractEdge, isEntityEdge, isFieldEdge } from './edge';
|
|
2
|
-
import { SatisfiabilityError } from './errors';
|
|
1
|
+
import { isAbstractEdge, isEntityEdge, isFieldEdge } from './edge.js';
|
|
2
|
+
import { SatisfiabilityError } from './errors.js';
|
|
3
3
|
export function concatIfNotExistsString(list, item) {
|
|
4
4
|
if (list.includes(item)) {
|
|
5
5
|
return list;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { specifiedScalarTypes } from 'graphql';
|
|
2
|
-
import { stripTypeModifiers } from '../../../../utils/state';
|
|
3
|
-
import { SUPERGRAPH_ID } from './constants';
|
|
4
|
-
import { assertAbstractEdge, assertFieldEdge, Edge, isAbstractEdge, isEntityEdge, isFieldEdge, } from './edge';
|
|
5
|
-
import { scoreKeyFields } from './helpers';
|
|
6
|
-
import { AbstractMove, EntityMove, FieldMove } from './moves';
|
|
7
|
-
import { Node } from './node';
|
|
2
|
+
import { stripTypeModifiers } from '../../../../utils/state.js';
|
|
3
|
+
import { SUPERGRAPH_ID } from './constants.js';
|
|
4
|
+
import { assertAbstractEdge, assertFieldEdge, Edge, isAbstractEdge, isEntityEdge, isFieldEdge, } from './edge.js';
|
|
5
|
+
import { scoreKeyFields } from './helpers.js';
|
|
6
|
+
import { AbstractMove, EntityMove, FieldMove } from './moves.js';
|
|
7
|
+
import { Node } from './node.js';
|
|
8
8
|
export class Graph {
|
|
9
9
|
name;
|
|
10
10
|
supergraphState;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { isEntityEdge, isFieldEdge } from './edge';
|
|
2
|
-
import { SatisfiabilityError } from './errors';
|
|
3
|
-
import { concatIfNotExistsFields, concatIfNotExistsString, PathFinder } from './finder';
|
|
1
|
+
import { isEntityEdge, isFieldEdge } from './edge.js';
|
|
2
|
+
import { SatisfiabilityError } from './errors.js';
|
|
3
|
+
import { concatIfNotExistsFields, concatIfNotExistsString, PathFinder } from './finder.js';
|
|
4
4
|
export class MoveValidator {
|
|
5
5
|
supergraph;
|
|
6
6
|
cache = new Map();
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { Logger, LoggerContext } from '../../../../utils/logger';
|
|
2
|
-
import { SUPERGRAPH_ID } from './constants';
|
|
3
|
-
import { FieldsResolver } from './fields';
|
|
4
|
-
import { Graph } from './graph';
|
|
5
|
-
import { MoveValidator } from './move-validator';
|
|
6
|
-
import { Walker } from './walker';
|
|
1
|
+
import { Logger, LoggerContext } from '../../../../utils/logger.js';
|
|
2
|
+
import { SUPERGRAPH_ID } from './constants.js';
|
|
3
|
+
import { FieldsResolver } from './fields.js';
|
|
4
|
+
import { Graph } from './graph.js';
|
|
5
|
+
import { MoveValidator } from './move-validator.js';
|
|
6
|
+
import { Walker } from './walker.js';
|
|
7
7
|
export class Supergraph {
|
|
8
8
|
supergraph;
|
|
9
9
|
mergedGraph;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { OperationTypeNode } from 'graphql';
|
|
2
|
-
import { isAbstractEdge, isFieldEdge } from './edge';
|
|
3
|
-
import { PathFinder } from './finder';
|
|
4
|
-
import { OperationPath } from './operation-path';
|
|
2
|
+
import { isAbstractEdge, isFieldEdge } from './edge.js';
|
|
3
|
+
import { PathFinder } from './finder.js';
|
|
4
|
+
import { OperationPath } from './operation-path.js';
|
|
5
5
|
export class WalkTracker {
|
|
6
6
|
superPath;
|
|
7
7
|
paths;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { SatisfiabilityError } from './errors';
|
|
2
|
-
import { AbstractMove, EntityMove, FieldMove, Move } from './moves';
|
|
3
|
-
import { Node } from './node';
|
|
1
|
+
import { SatisfiabilityError } from './errors.cjs';
|
|
2
|
+
import { AbstractMove, EntityMove, FieldMove, Move } from './moves.cjs';
|
|
3
|
+
import { Node } from './node.cjs';
|
|
4
4
|
type EdgeResolvabilityResult = {
|
|
5
5
|
success: true;
|
|
6
6
|
error: undefined;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { SatisfiabilityError } from './errors';
|
|
2
|
-
import { AbstractMove, EntityMove, FieldMove, Move } from './moves';
|
|
3
|
-
import { Node } from './node';
|
|
1
|
+
import { SatisfiabilityError } from './errors.js';
|
|
2
|
+
import { AbstractMove, EntityMove, FieldMove, Move } from './moves.js';
|
|
3
|
+
import { Node } from './node.js';
|
|
4
4
|
type EdgeResolvabilityResult = {
|
|
5
5
|
success: true;
|
|
6
6
|
error: undefined;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import type { Logger } from '../../../../utils/logger';
|
|
2
|
-
import { Edge } from './edge';
|
|
3
|
-
import { SatisfiabilityError } from './errors';
|
|
4
|
-
import { Fields } from './fields';
|
|
5
|
-
import type { Graph } from './graph';
|
|
6
|
-
import type { MoveValidator } from './move-validator';
|
|
7
|
-
import type { OperationPath } from './operation-path';
|
|
1
|
+
import type { Logger } from '../../../../utils/logger.cjs';
|
|
2
|
+
import { Edge } from './edge.cjs';
|
|
3
|
+
import { SatisfiabilityError } from './errors.cjs';
|
|
4
|
+
import { Fields } from './fields.cjs';
|
|
5
|
+
import type { Graph } from './graph.cjs';
|
|
6
|
+
import type { MoveValidator } from './move-validator.cjs';
|
|
7
|
+
import type { OperationPath } from './operation-path.cjs';
|
|
8
8
|
export declare function concatIfNotExistsString(list: string[], item: string): string[];
|
|
9
9
|
export declare function concatIfNotExistsFields(list: Fields[], item: Fields): Fields[];
|
|
10
10
|
type PathFinderResult = {
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import type { Logger } from '../../../../utils/logger';
|
|
2
|
-
import { Edge } from './edge';
|
|
3
|
-
import { SatisfiabilityError } from './errors';
|
|
4
|
-
import { Fields } from './fields';
|
|
5
|
-
import type { Graph } from './graph';
|
|
6
|
-
import type { MoveValidator } from './move-validator';
|
|
7
|
-
import type { OperationPath } from './operation-path';
|
|
1
|
+
import type { Logger } from '../../../../utils/logger.js';
|
|
2
|
+
import { Edge } from './edge.js';
|
|
3
|
+
import { SatisfiabilityError } from './errors.js';
|
|
4
|
+
import { Fields } from './fields.js';
|
|
5
|
+
import type { Graph } from './graph.js';
|
|
6
|
+
import type { MoveValidator } from './move-validator.js';
|
|
7
|
+
import type { OperationPath } from './operation-path.js';
|
|
8
8
|
export declare function concatIfNotExistsString(list: string[], item: string): string[];
|
|
9
9
|
export declare function concatIfNotExistsFields(list: Fields[], item: Fields): Fields[];
|
|
10
10
|
type PathFinderResult = {
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import type { Logger } from '../../../../utils/logger';
|
|
2
|
-
import type { SupergraphState } from '../../../state';
|
|
3
|
-
import { Edge } from './edge';
|
|
4
|
-
import type { FieldsResolver } from './fields';
|
|
5
|
-
import { Node } from './node';
|
|
1
|
+
import type { Logger } from '../../../../utils/logger.cjs';
|
|
2
|
+
import type { SupergraphState } from '../../../state.cjs';
|
|
3
|
+
import { Edge } from './edge.cjs';
|
|
4
|
+
import type { FieldsResolver } from './fields.cjs';
|
|
5
|
+
import { Node } from './node.cjs';
|
|
6
6
|
export declare class Graph {
|
|
7
7
|
name: string;
|
|
8
8
|
private supergraphState;
|
|
@@ -37,11 +37,11 @@ export declare class Graph {
|
|
|
37
37
|
nodesOf(typeName: string, failIfMissing?: boolean): Node[];
|
|
38
38
|
private getSameGraphEdgesOfIndex;
|
|
39
39
|
fieldEdgesOfHead(head: Node, fieldName: string): Edge[];
|
|
40
|
-
abstractEdgesOfHead(head: Node): Edge<import("./moves").Move>[];
|
|
41
|
-
entityEdgesOfHead(head: Node): Edge<import("./moves").Move>[];
|
|
42
|
-
crossGraphEdgesOfHead(head: Node): Edge<import("./moves").Move>[];
|
|
43
|
-
edgesOfHead(head: Node): Edge<import("./moves").Move>[];
|
|
44
|
-
edgesOfTail(tail: Node): Edge<import("./moves").Move>[];
|
|
40
|
+
abstractEdgesOfHead(head: Node): Edge<import("./moves.js").Move>[];
|
|
41
|
+
entityEdgesOfHead(head: Node): Edge<import("./moves.js").Move>[];
|
|
42
|
+
crossGraphEdgesOfHead(head: Node): Edge<import("./moves.js").Move>[];
|
|
43
|
+
edgesOfHead(head: Node): Edge<import("./moves.js").Move>[];
|
|
44
|
+
edgesOfTail(tail: Node): Edge<import("./moves.js").Move>[];
|
|
45
45
|
possibleTypesOf(typeName: string): string[];
|
|
46
46
|
canReachTypeFromType(fromTypeName: string, toTypeName: string): boolean;
|
|
47
47
|
private createNodesAndEdgesForType;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import type { Logger } from '../../../../utils/logger';
|
|
2
|
-
import type { SupergraphState } from '../../../state';
|
|
3
|
-
import { Edge } from './edge';
|
|
4
|
-
import type { FieldsResolver } from './fields';
|
|
5
|
-
import { Node } from './node';
|
|
1
|
+
import type { Logger } from '../../../../utils/logger.js';
|
|
2
|
+
import type { SupergraphState } from '../../../state.js';
|
|
3
|
+
import { Edge } from './edge.js';
|
|
4
|
+
import type { FieldsResolver } from './fields.js';
|
|
5
|
+
import { Node } from './node.js';
|
|
6
6
|
export declare class Graph {
|
|
7
7
|
name: string;
|
|
8
8
|
private supergraphState;
|
|
@@ -37,11 +37,11 @@ export declare class Graph {
|
|
|
37
37
|
nodesOf(typeName: string, failIfMissing?: boolean): Node[];
|
|
38
38
|
private getSameGraphEdgesOfIndex;
|
|
39
39
|
fieldEdgesOfHead(head: Node, fieldName: string): Edge[];
|
|
40
|
-
abstractEdgesOfHead(head: Node): Edge<import("./moves").Move>[];
|
|
41
|
-
entityEdgesOfHead(head: Node): Edge<import("./moves").Move>[];
|
|
42
|
-
crossGraphEdgesOfHead(head: Node): Edge<import("./moves").Move>[];
|
|
43
|
-
edgesOfHead(head: Node): Edge<import("./moves").Move>[];
|
|
44
|
-
edgesOfTail(tail: Node): Edge<import("./moves").Move>[];
|
|
40
|
+
abstractEdgesOfHead(head: Node): Edge<import("./moves.js").Move>[];
|
|
41
|
+
entityEdgesOfHead(head: Node): Edge<import("./moves.js").Move>[];
|
|
42
|
+
crossGraphEdgesOfHead(head: Node): Edge<import("./moves.js").Move>[];
|
|
43
|
+
edgesOfHead(head: Node): Edge<import("./moves.js").Move>[];
|
|
44
|
+
edgesOfTail(tail: Node): Edge<import("./moves.js").Move>[];
|
|
45
45
|
possibleTypesOf(typeName: string): string[];
|
|
46
46
|
canReachTypeFromType(fromTypeName: string, toTypeName: string): boolean;
|
|
47
47
|
private createNodesAndEdgesForType;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import type { Logger } from '../../../../utils/logger';
|
|
2
|
-
import { Edge } from './edge';
|
|
3
|
-
import { SatisfiabilityError } from './errors';
|
|
4
|
-
import type { Fields } from './fields';
|
|
5
|
-
import type { Graph } from './graph';
|
|
6
|
-
import { OperationPath } from './operation-path';
|
|
1
|
+
import type { Logger } from '../../../../utils/logger.cjs';
|
|
2
|
+
import { Edge } from './edge.cjs';
|
|
3
|
+
import { SatisfiabilityError } from './errors.cjs';
|
|
4
|
+
import type { Fields } from './fields.cjs';
|
|
5
|
+
import type { Graph } from './graph.cjs';
|
|
6
|
+
import { OperationPath } from './operation-path.cjs';
|
|
7
7
|
export declare class MoveValidator {
|
|
8
8
|
private supergraph;
|
|
9
9
|
private cache;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import type { Logger } from '../../../../utils/logger';
|
|
2
|
-
import { Edge } from './edge';
|
|
3
|
-
import { SatisfiabilityError } from './errors';
|
|
4
|
-
import type { Fields } from './fields';
|
|
5
|
-
import type { Graph } from './graph';
|
|
6
|
-
import { OperationPath } from './operation-path';
|
|
1
|
+
import type { Logger } from '../../../../utils/logger.js';
|
|
2
|
+
import { Edge } from './edge.js';
|
|
3
|
+
import { SatisfiabilityError } from './errors.js';
|
|
4
|
+
import type { Fields } from './fields.js';
|
|
5
|
+
import type { Graph } from './graph.js';
|
|
6
|
+
import { OperationPath } from './operation-path.js';
|
|
7
7
|
export declare class MoveValidator {
|
|
8
8
|
private supergraph;
|
|
9
9
|
private cache;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import type { EnumTypeState } from '../../../composition/enum-type';
|
|
2
|
-
import type { InterfaceTypeState } from '../../../composition/interface-type';
|
|
3
|
-
import type { ObjectTypeState } from '../../../composition/object-type';
|
|
4
|
-
import type { ScalarTypeState } from '../../../composition/scalar-type';
|
|
5
|
-
import type { UnionTypeState } from '../../../composition/union-type';
|
|
1
|
+
import type { EnumTypeState } from '../../../composition/enum-type.cjs';
|
|
2
|
+
import type { InterfaceTypeState } from '../../../composition/interface-type.cjs';
|
|
3
|
+
import type { ObjectTypeState } from '../../../composition/object-type.cjs';
|
|
4
|
+
import type { ScalarTypeState } from '../../../composition/scalar-type.cjs';
|
|
5
|
+
import type { UnionTypeState } from '../../../composition/union-type.cjs';
|
|
6
6
|
export declare class Node {
|
|
7
7
|
index: number;
|
|
8
8
|
typeName: string;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import type { EnumTypeState } from '../../../composition/enum-type';
|
|
2
|
-
import type { InterfaceTypeState } from '../../../composition/interface-type';
|
|
3
|
-
import type { ObjectTypeState } from '../../../composition/object-type';
|
|
4
|
-
import type { ScalarTypeState } from '../../../composition/scalar-type';
|
|
5
|
-
import type { UnionTypeState } from '../../../composition/union-type';
|
|
1
|
+
import type { EnumTypeState } from '../../../composition/enum-type.js';
|
|
2
|
+
import type { InterfaceTypeState } from '../../../composition/interface-type.js';
|
|
3
|
+
import type { ObjectTypeState } from '../../../composition/object-type.js';
|
|
4
|
+
import type { ScalarTypeState } from '../../../composition/scalar-type.js';
|
|
5
|
+
import type { UnionTypeState } from '../../../composition/union-type.js';
|
|
6
6
|
export declare class Node {
|
|
7
7
|
index: number;
|
|
8
8
|
typeName: string;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { OperationTypeNode } from 'graphql';
|
|
2
|
-
import type { SupergraphState } from '../../../state';
|
|
3
|
-
import { Step } from './operation-path';
|
|
2
|
+
import type { SupergraphState } from '../../../state.cjs';
|
|
3
|
+
import { Step } from './operation-path.cjs';
|
|
4
4
|
export declare class Supergraph {
|
|
5
5
|
private supergraph;
|
|
6
6
|
private mergedGraph;
|
|
@@ -8,7 +8,7 @@ export declare class Supergraph {
|
|
|
8
8
|
private moveRequirementChecker;
|
|
9
9
|
private logger;
|
|
10
10
|
constructor(supergraphState: SupergraphState);
|
|
11
|
-
validate(): import("./walker").WalkTracker[];
|
|
12
|
-
validateOperation(operation: OperationTypeNode, steps: Step[]): import("./walker").WalkTracker;
|
|
11
|
+
validate(): import("./walker.js").WalkTracker[];
|
|
12
|
+
validateOperation(operation: OperationTypeNode, steps: Step[]): import("./walker.js").WalkTracker;
|
|
13
13
|
}
|
|
14
14
|
//# sourceMappingURL=supergraph.d.ts.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { OperationTypeNode } from 'graphql';
|
|
2
|
-
import type { SupergraphState } from '../../../state';
|
|
3
|
-
import { Step } from './operation-path';
|
|
2
|
+
import type { SupergraphState } from '../../../state.js';
|
|
3
|
+
import { Step } from './operation-path.js';
|
|
4
4
|
export declare class Supergraph {
|
|
5
5
|
private supergraph;
|
|
6
6
|
private mergedGraph;
|
|
@@ -8,7 +8,7 @@ export declare class Supergraph {
|
|
|
8
8
|
private moveRequirementChecker;
|
|
9
9
|
private logger;
|
|
10
10
|
constructor(supergraphState: SupergraphState);
|
|
11
|
-
validate(): import("./walker").WalkTracker[];
|
|
12
|
-
validateOperation(operation: OperationTypeNode, steps: Step[]): import("./walker").WalkTracker;
|
|
11
|
+
validate(): import("./walker.js").WalkTracker[];
|
|
12
|
+
validateOperation(operation: OperationTypeNode, steps: Step[]): import("./walker.js").WalkTracker;
|
|
13
13
|
}
|
|
14
14
|
//# sourceMappingURL=supergraph.d.ts.map
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { OperationTypeNode } from 'graphql';
|
|
2
|
-
import type { Logger } from '../../../../utils/logger';
|
|
3
|
-
import { type Edge } from './edge';
|
|
4
|
-
import { SatisfiabilityError } from './errors';
|
|
5
|
-
import type { Graph } from './graph';
|
|
6
|
-
import type { MoveValidator } from './move-validator';
|
|
7
|
-
import { OperationPath, type Step } from './operation-path';
|
|
2
|
+
import type { Logger } from '../../../../utils/logger.cjs';
|
|
3
|
+
import { type Edge } from './edge.cjs';
|
|
4
|
+
import { SatisfiabilityError } from './errors.cjs';
|
|
5
|
+
import type { Graph } from './graph.cjs';
|
|
6
|
+
import type { MoveValidator } from './move-validator.cjs';
|
|
7
|
+
import { OperationPath, type Step } from './operation-path.cjs';
|
|
8
8
|
export declare class WalkTracker {
|
|
9
9
|
superPath: OperationPath;
|
|
10
10
|
paths: OperationPath[];
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { OperationTypeNode } from 'graphql';
|
|
2
|
-
import type { Logger } from '../../../../utils/logger';
|
|
3
|
-
import { type Edge } from './edge';
|
|
4
|
-
import { SatisfiabilityError } from './errors';
|
|
5
|
-
import type { Graph } from './graph';
|
|
6
|
-
import type { MoveValidator } from './move-validator';
|
|
7
|
-
import { OperationPath, type Step } from './operation-path';
|
|
2
|
+
import type { Logger } from '../../../../utils/logger.js';
|
|
3
|
+
import { type Edge } from './edge.js';
|
|
4
|
+
import { SatisfiabilityError } from './errors.js';
|
|
5
|
+
import type { Graph } from './graph.js';
|
|
6
|
+
import type { MoveValidator } from './move-validator.js';
|
|
7
|
+
import { OperationPath, type Step } from './operation-path.js';
|
|
8
8
|
export declare class WalkTracker {
|
|
9
9
|
superPath: OperationPath;
|
|
10
10
|
paths: OperationPath[];
|