@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.
Files changed (3) hide show
  1. package/cjs/index.js +13 -17
  2. package/esm/index.js +13 -17
  3. 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 ((_a = this.config) === null || _a === void 0 ? void 0 : _a.types) {
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 ((_b = type.config) === null || _b === void 0 ? void 0 : _b.key) {
42
+ if (type.config?.key) {
44
43
  typeDirectivesObj.key = type.config.key;
45
44
  }
46
- if ((_c = type.config) === null || _c === void 0 ? void 0 : _c.shareable) {
45
+ if (type.config?.shareable) {
47
46
  typeDirectivesObj.shareable = type.config.shareable;
48
47
  }
49
- if ((_d = type.config) === null || _d === void 0 ? void 0 : _d.extends) {
48
+ if (type.config?.extends) {
50
49
  typeDirectivesObj.extends = type.config.extends;
51
50
  }
52
51
  const typeFieldObjs = typeObj.getFields();
53
- if ((_e = type.config) === null || _e === void 0 ? void 0 : _e.fields) {
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 ((_f = type.config) === null || _f === void 0 ? void 0 : _f.key) {
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 ((_g = type.config) === null || _g === void 0 ? void 0 : _g.resolveReference) {
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: (_a = type.astNode.directives) === null || _a === void 0 ? void 0 : _a.filter(directive => federationDirectives.includes(directive.name.value)),
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(((_b = type.extensions) === null || _b === void 0 ? void 0 : _b.directives) || {}).filter(([key]) => federationDirectives.includes(key))),
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: (_a = type.astNode.directives) === null || _a === void 0 ? void 0 : _a.filter(directive => federationDirectives.includes(directive.name.value)),
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(((_b = type.extensions) === null || _b === void 0 ? void 0 : _b.directives) || {}).filter(([key]) => federationDirectives.includes(key))),
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: (_a = fieldConfig.astNode.directives) === null || _a === void 0 ? void 0 : _a.filter(directive => federationDirectives.includes(directive.name.value)),
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(((_b = fieldConfig.extensions) === null || _b === void 0 ? void 0 : _b.directives) || {}).filter(([key]) => federationDirectives.includes(key))),
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 ((_a = this.config) === null || _a === void 0 ? void 0 : _a.types) {
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 ((_b = type.config) === null || _b === void 0 ? void 0 : _b.key) {
40
+ if (type.config?.key) {
42
41
  typeDirectivesObj.key = type.config.key;
43
42
  }
44
- if ((_c = type.config) === null || _c === void 0 ? void 0 : _c.shareable) {
43
+ if (type.config?.shareable) {
45
44
  typeDirectivesObj.shareable = type.config.shareable;
46
45
  }
47
- if ((_d = type.config) === null || _d === void 0 ? void 0 : _d.extends) {
46
+ if (type.config?.extends) {
48
47
  typeDirectivesObj.extends = type.config.extends;
49
48
  }
50
49
  const typeFieldObjs = typeObj.getFields();
51
- if ((_e = type.config) === null || _e === void 0 ? void 0 : _e.fields) {
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 ((_f = type.config) === null || _f === void 0 ? void 0 : _f.key) {
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 ((_g = type.config) === null || _g === void 0 ? void 0 : _g.resolveReference) {
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: (_a = type.astNode.directives) === null || _a === void 0 ? void 0 : _a.filter(directive => federationDirectives.includes(directive.name.value)),
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(((_b = type.extensions) === null || _b === void 0 ? void 0 : _b.directives) || {}).filter(([key]) => federationDirectives.includes(key))),
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: (_a = type.astNode.directives) === null || _a === void 0 ? void 0 : _a.filter(directive => federationDirectives.includes(directive.name.value)),
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(((_b = type.extensions) === null || _b === void 0 ? void 0 : _b.directives) || {}).filter(([key]) => federationDirectives.includes(key))),
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: (_a = fieldConfig.astNode.directives) === null || _a === void 0 ? void 0 : _a.filter(directive => federationDirectives.includes(directive.name.value)),
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(((_b = fieldConfig.extensions) === null || _b === void 0 ? void 0 : _b.directives) || {}).filter(([key]) => federationDirectives.includes(key))),
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-20230523154231-8c60b52d9",
3
+ "version": "1.0.0-alpha-20230523155104-df277a22b",
4
4
  "sideEffects": false,
5
5
  "peerDependencies": {
6
- "@graphql-mesh/types": "1.0.0-alpha-20230523154231-8c60b52d9",
7
- "@graphql-mesh/utils": "1.0.0-alpha-20230523154231-8c60b52d9",
8
- "@graphql-tools/utils": "^9.2.1 || ^10.0.0",
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-20230523154231-8c60b52d9",
15
- "@graphql-tools/delegate": "^10.0.0",
16
- "@graphql-tools/stitching-directives": "^3.0.0",
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",