@graphql-mesh/transform-federation 1.0.0-alpha-20230523154231-8c60b52d9 → 1.0.0-alpha-20230523155104-df277a22b
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/index.js +13 -17
- package/esm/index.js +13 -17
- package/package.json +10 -7
package/cjs/index.js
CHANGED
|
@@ -29,9 +29,8 @@ class FederationTransform {
|
|
|
29
29
|
this.importFn = importFn;
|
|
30
30
|
}
|
|
31
31
|
transformSchema(schema, rawSource) {
|
|
32
|
-
var _a, _b, _c, _d, _e, _f, _g;
|
|
33
32
|
rawSource.merge = {};
|
|
34
|
-
if (
|
|
33
|
+
if (this.config?.types) {
|
|
35
34
|
const queryType = schema.getQueryType();
|
|
36
35
|
const queryTypeFields = queryType.getFields();
|
|
37
36
|
for (const type of this.config.types) {
|
|
@@ -40,17 +39,17 @@ class FederationTransform {
|
|
|
40
39
|
typeObj.extensions = typeObj.extensions || {};
|
|
41
40
|
const typeDirectivesObj = (typeObj.extensions.directives =
|
|
42
41
|
typeObj.extensions.directives || {});
|
|
43
|
-
if (
|
|
42
|
+
if (type.config?.key) {
|
|
44
43
|
typeDirectivesObj.key = type.config.key;
|
|
45
44
|
}
|
|
46
|
-
if (
|
|
45
|
+
if (type.config?.shareable) {
|
|
47
46
|
typeDirectivesObj.shareable = type.config.shareable;
|
|
48
47
|
}
|
|
49
|
-
if (
|
|
48
|
+
if (type.config?.extends) {
|
|
50
49
|
typeDirectivesObj.extends = type.config.extends;
|
|
51
50
|
}
|
|
52
51
|
const typeFieldObjs = typeObj.getFields();
|
|
53
|
-
if (
|
|
52
|
+
if (type.config?.fields) {
|
|
54
53
|
for (const field of type.config.fields) {
|
|
55
54
|
const typeField = typeFieldObjs[field.name];
|
|
56
55
|
if (typeField) {
|
|
@@ -69,7 +68,7 @@ class FederationTransform {
|
|
|
69
68
|
}
|
|
70
69
|
}
|
|
71
70
|
// If a field is a key field, it should be GraphQLID
|
|
72
|
-
if (
|
|
71
|
+
if (type.config?.key) {
|
|
73
72
|
let selectionSetContent = '';
|
|
74
73
|
for (const keyField of type.config.key) {
|
|
75
74
|
selectionSetContent += '\n';
|
|
@@ -80,7 +79,7 @@ class FederationTransform {
|
|
|
80
79
|
}
|
|
81
80
|
}
|
|
82
81
|
let resolveReference;
|
|
83
|
-
if (
|
|
82
|
+
if (type.config?.resolveReference) {
|
|
84
83
|
const resolveReferenceConfig = type.config.resolveReference;
|
|
85
84
|
if (typeof resolveReferenceConfig === 'string') {
|
|
86
85
|
const fn$ = (0, utils_1.loadFromModuleExportExpression)(resolveReferenceConfig, {
|
|
@@ -184,44 +183,41 @@ class FederationTransform {
|
|
|
184
183
|
return null;
|
|
185
184
|
},
|
|
186
185
|
[utils_2.MapperKind.OBJECT_TYPE]: type => {
|
|
187
|
-
var _a, _b;
|
|
188
186
|
return new graphql_1.GraphQLObjectType({
|
|
189
187
|
...type.toConfig(),
|
|
190
188
|
astNode: type.astNode && {
|
|
191
189
|
...type.astNode,
|
|
192
|
-
directives:
|
|
190
|
+
directives: type.astNode.directives?.filter(directive => federationDirectives.includes(directive.name.value)),
|
|
193
191
|
},
|
|
194
192
|
extensions: {
|
|
195
193
|
...type.extensions,
|
|
196
|
-
directives: Object.fromEntries(Object.entries(
|
|
194
|
+
directives: Object.fromEntries(Object.entries(type.extensions?.directives || {}).filter(([key]) => federationDirectives.includes(key))),
|
|
197
195
|
},
|
|
198
196
|
});
|
|
199
197
|
},
|
|
200
198
|
[utils_2.MapperKind.INTERFACE_TYPE]: type => {
|
|
201
|
-
var _a, _b;
|
|
202
199
|
return new graphql_1.GraphQLInterfaceType({
|
|
203
200
|
...type.toConfig(),
|
|
204
201
|
astNode: type.astNode && {
|
|
205
202
|
...type.astNode,
|
|
206
|
-
directives:
|
|
203
|
+
directives: type.astNode.directives?.filter(directive => federationDirectives.includes(directive.name.value)),
|
|
207
204
|
},
|
|
208
205
|
extensions: {
|
|
209
206
|
...type.extensions,
|
|
210
|
-
directives: Object.fromEntries(Object.entries(
|
|
207
|
+
directives: Object.fromEntries(Object.entries(type.extensions?.directives || {}).filter(([key]) => federationDirectives.includes(key))),
|
|
211
208
|
},
|
|
212
209
|
});
|
|
213
210
|
},
|
|
214
211
|
[utils_2.MapperKind.COMPOSITE_FIELD]: fieldConfig => {
|
|
215
|
-
var _a, _b;
|
|
216
212
|
return {
|
|
217
213
|
...fieldConfig,
|
|
218
214
|
astNode: fieldConfig.astNode && {
|
|
219
215
|
...fieldConfig.astNode,
|
|
220
|
-
directives:
|
|
216
|
+
directives: fieldConfig.astNode.directives?.filter(directive => federationDirectives.includes(directive.name.value)),
|
|
221
217
|
},
|
|
222
218
|
extensions: {
|
|
223
219
|
...fieldConfig.extensions,
|
|
224
|
-
directives: Object.fromEntries(Object.entries(
|
|
220
|
+
directives: Object.fromEntries(Object.entries(fieldConfig.extensions?.directives || {}).filter(([key]) => federationDirectives.includes(key))),
|
|
225
221
|
},
|
|
226
222
|
};
|
|
227
223
|
},
|
package/esm/index.js
CHANGED
|
@@ -27,9 +27,8 @@ export default class FederationTransform {
|
|
|
27
27
|
this.importFn = importFn;
|
|
28
28
|
}
|
|
29
29
|
transformSchema(schema, rawSource) {
|
|
30
|
-
var _a, _b, _c, _d, _e, _f, _g;
|
|
31
30
|
rawSource.merge = {};
|
|
32
|
-
if (
|
|
31
|
+
if (this.config?.types) {
|
|
33
32
|
const queryType = schema.getQueryType();
|
|
34
33
|
const queryTypeFields = queryType.getFields();
|
|
35
34
|
for (const type of this.config.types) {
|
|
@@ -38,17 +37,17 @@ export default class FederationTransform {
|
|
|
38
37
|
typeObj.extensions = typeObj.extensions || {};
|
|
39
38
|
const typeDirectivesObj = (typeObj.extensions.directives =
|
|
40
39
|
typeObj.extensions.directives || {});
|
|
41
|
-
if (
|
|
40
|
+
if (type.config?.key) {
|
|
42
41
|
typeDirectivesObj.key = type.config.key;
|
|
43
42
|
}
|
|
44
|
-
if (
|
|
43
|
+
if (type.config?.shareable) {
|
|
45
44
|
typeDirectivesObj.shareable = type.config.shareable;
|
|
46
45
|
}
|
|
47
|
-
if (
|
|
46
|
+
if (type.config?.extends) {
|
|
48
47
|
typeDirectivesObj.extends = type.config.extends;
|
|
49
48
|
}
|
|
50
49
|
const typeFieldObjs = typeObj.getFields();
|
|
51
|
-
if (
|
|
50
|
+
if (type.config?.fields) {
|
|
52
51
|
for (const field of type.config.fields) {
|
|
53
52
|
const typeField = typeFieldObjs[field.name];
|
|
54
53
|
if (typeField) {
|
|
@@ -67,7 +66,7 @@ export default class FederationTransform {
|
|
|
67
66
|
}
|
|
68
67
|
}
|
|
69
68
|
// If a field is a key field, it should be GraphQLID
|
|
70
|
-
if (
|
|
69
|
+
if (type.config?.key) {
|
|
71
70
|
let selectionSetContent = '';
|
|
72
71
|
for (const keyField of type.config.key) {
|
|
73
72
|
selectionSetContent += '\n';
|
|
@@ -78,7 +77,7 @@ export default class FederationTransform {
|
|
|
78
77
|
}
|
|
79
78
|
}
|
|
80
79
|
let resolveReference;
|
|
81
|
-
if (
|
|
80
|
+
if (type.config?.resolveReference) {
|
|
82
81
|
const resolveReferenceConfig = type.config.resolveReference;
|
|
83
82
|
if (typeof resolveReferenceConfig === 'string') {
|
|
84
83
|
const fn$ = loadFromModuleExportExpression(resolveReferenceConfig, {
|
|
@@ -182,44 +181,41 @@ export default class FederationTransform {
|
|
|
182
181
|
return null;
|
|
183
182
|
},
|
|
184
183
|
[MapperKind.OBJECT_TYPE]: type => {
|
|
185
|
-
var _a, _b;
|
|
186
184
|
return new GraphQLObjectType({
|
|
187
185
|
...type.toConfig(),
|
|
188
186
|
astNode: type.astNode && {
|
|
189
187
|
...type.astNode,
|
|
190
|
-
directives:
|
|
188
|
+
directives: type.astNode.directives?.filter(directive => federationDirectives.includes(directive.name.value)),
|
|
191
189
|
},
|
|
192
190
|
extensions: {
|
|
193
191
|
...type.extensions,
|
|
194
|
-
directives: Object.fromEntries(Object.entries(
|
|
192
|
+
directives: Object.fromEntries(Object.entries(type.extensions?.directives || {}).filter(([key]) => federationDirectives.includes(key))),
|
|
195
193
|
},
|
|
196
194
|
});
|
|
197
195
|
},
|
|
198
196
|
[MapperKind.INTERFACE_TYPE]: type => {
|
|
199
|
-
var _a, _b;
|
|
200
197
|
return new GraphQLInterfaceType({
|
|
201
198
|
...type.toConfig(),
|
|
202
199
|
astNode: type.astNode && {
|
|
203
200
|
...type.astNode,
|
|
204
|
-
directives:
|
|
201
|
+
directives: type.astNode.directives?.filter(directive => federationDirectives.includes(directive.name.value)),
|
|
205
202
|
},
|
|
206
203
|
extensions: {
|
|
207
204
|
...type.extensions,
|
|
208
|
-
directives: Object.fromEntries(Object.entries(
|
|
205
|
+
directives: Object.fromEntries(Object.entries(type.extensions?.directives || {}).filter(([key]) => federationDirectives.includes(key))),
|
|
209
206
|
},
|
|
210
207
|
});
|
|
211
208
|
},
|
|
212
209
|
[MapperKind.COMPOSITE_FIELD]: fieldConfig => {
|
|
213
|
-
var _a, _b;
|
|
214
210
|
return {
|
|
215
211
|
...fieldConfig,
|
|
216
212
|
astNode: fieldConfig.astNode && {
|
|
217
213
|
...fieldConfig.astNode,
|
|
218
|
-
directives:
|
|
214
|
+
directives: fieldConfig.astNode.directives?.filter(directive => federationDirectives.includes(directive.name.value)),
|
|
219
215
|
},
|
|
220
216
|
extensions: {
|
|
221
217
|
...fieldConfig.extensions,
|
|
222
|
-
directives: Object.fromEntries(Object.entries(
|
|
218
|
+
directives: Object.fromEntries(Object.entries(fieldConfig.extensions?.directives || {}).filter(([key]) => federationDirectives.includes(key))),
|
|
223
219
|
},
|
|
224
220
|
};
|
|
225
221
|
},
|
package/package.json
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@graphql-mesh/transform-federation",
|
|
3
|
-
"version": "1.0.0-alpha-
|
|
3
|
+
"version": "1.0.0-alpha-20230523155104-df277a22b",
|
|
4
4
|
"sideEffects": false,
|
|
5
5
|
"peerDependencies": {
|
|
6
|
-
"@graphql-mesh/types": "1.0.0-alpha-
|
|
7
|
-
"@graphql-mesh/utils": "1.0.0-alpha-
|
|
8
|
-
"@graphql-tools/utils": "^9.2.1
|
|
6
|
+
"@graphql-mesh/types": "1.0.0-alpha-20230523155104-df277a22b",
|
|
7
|
+
"@graphql-mesh/utils": "1.0.0-alpha-20230523155104-df277a22b",
|
|
8
|
+
"@graphql-tools/utils": "^9.2.1",
|
|
9
9
|
"graphql": "*",
|
|
10
10
|
"tslib": "^2.4.0"
|
|
11
11
|
},
|
|
12
12
|
"dependencies": {
|
|
13
13
|
"@apollo/subgraph": "^2.4.1",
|
|
14
|
-
"@graphql-mesh/string-interpolation": "0.5.0-alpha-
|
|
15
|
-
"@graphql-tools/delegate": "^
|
|
16
|
-
"@graphql-tools/stitching-directives": "^3.
|
|
14
|
+
"@graphql-mesh/string-interpolation": "0.5.0-alpha-20230523155104-df277a22b",
|
|
15
|
+
"@graphql-tools/delegate": "^9.0.32",
|
|
16
|
+
"@graphql-tools/stitching-directives": "^2.3.34",
|
|
17
17
|
"dset": "^3.1.2",
|
|
18
18
|
"graphql-transform-federation": "^2.2.0"
|
|
19
19
|
},
|
|
@@ -23,6 +23,9 @@
|
|
|
23
23
|
"directory": "packages/transforms/federation"
|
|
24
24
|
},
|
|
25
25
|
"license": "MIT",
|
|
26
|
+
"engines": {
|
|
27
|
+
"node": ">=16.0.0"
|
|
28
|
+
},
|
|
26
29
|
"main": "cjs/index.js",
|
|
27
30
|
"module": "esm/index.js",
|
|
28
31
|
"typings": "typings/index.d.ts",
|