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