@theguild/federation-composition 0.5.0 → 0.5.1-rc-20231214204251-35140eb
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
CHANGED
|
@@ -98,6 +98,21 @@ pnpm test
|
|
|
98
98
|
- Look for `skipIf` or `skip` in the tests.
|
|
99
99
|
- Refactor code (piece by piece) if you feel like it.
|
|
100
100
|
|
|
101
|
+
### Compatibility
|
|
102
|
+
|
|
103
|
+
The lack of a publicly available specification for Apollo Federation, coupled with the non
|
|
104
|
+
open-source license of the Apollo Composition library, makes it difficult or even impossible to
|
|
105
|
+
assure complete compatibility of our open-source composition library.
|
|
106
|
+
|
|
107
|
+
Given that Apollo tools utilize their composition library, there is a potential for conflicting
|
|
108
|
+
results between our composition library and Apollo's. This may lead to variations in the supergraph,
|
|
109
|
+
differing composition errors, or, in some cases, conflicting composition outcomes.
|
|
110
|
+
|
|
111
|
+
We are working to ensure that our composition library is as compatible as possible with Apollo's and
|
|
112
|
+
will continue to do so as we learn more about the Federation specification.
|
|
113
|
+
|
|
114
|
+
Your feedback and bug reports are welcome and appreciated.
|
|
115
|
+
|
|
101
116
|
## Supergraph SDL Composition
|
|
102
117
|
|
|
103
118
|
✅ Done
|
|
@@ -4,11 +4,20 @@ exports.objectTypeBuilder = exports.isRealExtension = void 0;
|
|
|
4
4
|
const ast_js_1 = require("./ast.js");
|
|
5
5
|
const common_js_1 = require("./common.js");
|
|
6
6
|
function isRealExtension(meta, version) {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
7
|
+
const hasExtendsDirective = meta.extensionType === '@extends';
|
|
8
|
+
if (meta.extension) {
|
|
9
|
+
if (version === 'v1.0' && !hasExtendsDirective) {
|
|
10
|
+
return false;
|
|
11
|
+
}
|
|
12
|
+
if (hasExtendsDirective) {
|
|
13
|
+
return true;
|
|
14
|
+
}
|
|
15
|
+
if (meta.hasDefinition) {
|
|
16
|
+
return false;
|
|
17
|
+
}
|
|
18
|
+
return true;
|
|
19
|
+
}
|
|
20
|
+
return false;
|
|
12
21
|
}
|
|
13
22
|
exports.isRealExtension = isRealExtension;
|
|
14
23
|
function objectTypeBuilder() {
|
|
@@ -42,6 +51,7 @@ function objectTypeBuilder() {
|
|
|
42
51
|
}
|
|
43
52
|
type.interfaces.forEach(interfaceName => objectTypeState.interfaces.add(interfaceName));
|
|
44
53
|
objectTypeState.byGraph.set(graph.id, {
|
|
54
|
+
hasDefinition: isDefinition,
|
|
45
55
|
extension: type.extension,
|
|
46
56
|
extensionType: type.extensionType,
|
|
47
57
|
external: type.external,
|
|
@@ -50,6 +60,7 @@ function objectTypeBuilder() {
|
|
|
50
60
|
shareable: type.shareable,
|
|
51
61
|
interfaces: type.interfaces,
|
|
52
62
|
});
|
|
63
|
+
const typeInGraph = objectTypeState.byGraph.get(graph.id);
|
|
53
64
|
for (const field of type.fields.values()) {
|
|
54
65
|
const fieldState = getOrCreateField(objectTypeState, field.name, field.type);
|
|
55
66
|
field.tags.forEach(tag => fieldState.tags.add(tag));
|
|
@@ -58,7 +69,7 @@ function objectTypeBuilder() {
|
|
|
58
69
|
fieldState.usedAsKey = true;
|
|
59
70
|
}
|
|
60
71
|
const isExternal = graph.version === 'v1.0'
|
|
61
|
-
? field.external && isRealExtension(
|
|
72
|
+
? field.external && isRealExtension(typeInGraph, graph.version)
|
|
62
73
|
: field.external;
|
|
63
74
|
const shouldForceType = !usedAsKey && !isExternal && !fieldState.internal.seenNonExternal;
|
|
64
75
|
const shouldChangeType = shouldForceType ||
|
|
@@ -1,11 +1,20 @@
|
|
|
1
1
|
import { createObjectTypeNode } from './ast.js';
|
|
2
2
|
import { convertToConst } from './common.js';
|
|
3
3
|
export function isRealExtension(meta, version) {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
4
|
+
const hasExtendsDirective = meta.extensionType === '@extends';
|
|
5
|
+
if (meta.extension) {
|
|
6
|
+
if (version === 'v1.0' && !hasExtendsDirective) {
|
|
7
|
+
return false;
|
|
8
|
+
}
|
|
9
|
+
if (hasExtendsDirective) {
|
|
10
|
+
return true;
|
|
11
|
+
}
|
|
12
|
+
if (meta.hasDefinition) {
|
|
13
|
+
return false;
|
|
14
|
+
}
|
|
15
|
+
return true;
|
|
16
|
+
}
|
|
17
|
+
return false;
|
|
9
18
|
}
|
|
10
19
|
export function objectTypeBuilder() {
|
|
11
20
|
return {
|
|
@@ -38,6 +47,7 @@ export function objectTypeBuilder() {
|
|
|
38
47
|
}
|
|
39
48
|
type.interfaces.forEach(interfaceName => objectTypeState.interfaces.add(interfaceName));
|
|
40
49
|
objectTypeState.byGraph.set(graph.id, {
|
|
50
|
+
hasDefinition: isDefinition,
|
|
41
51
|
extension: type.extension,
|
|
42
52
|
extensionType: type.extensionType,
|
|
43
53
|
external: type.external,
|
|
@@ -46,6 +56,7 @@ export function objectTypeBuilder() {
|
|
|
46
56
|
shareable: type.shareable,
|
|
47
57
|
interfaces: type.interfaces,
|
|
48
58
|
});
|
|
59
|
+
const typeInGraph = objectTypeState.byGraph.get(graph.id);
|
|
49
60
|
for (const field of type.fields.values()) {
|
|
50
61
|
const fieldState = getOrCreateField(objectTypeState, field.name, field.type);
|
|
51
62
|
field.tags.forEach(tag => fieldState.tags.add(tag));
|
|
@@ -54,7 +65,7 @@ export function objectTypeBuilder() {
|
|
|
54
65
|
fieldState.usedAsKey = true;
|
|
55
66
|
}
|
|
56
67
|
const isExternal = graph.version === 'v1.0'
|
|
57
|
-
? field.external && isRealExtension(
|
|
68
|
+
? field.external && isRealExtension(typeInGraph, graph.version)
|
|
58
69
|
: field.external;
|
|
59
70
|
const shouldForceType = !usedAsKey && !isExternal && !fieldState.internal.seenNonExternal;
|
|
60
71
|
const shouldChangeType = shouldForceType ||
|
package/package.json
CHANGED