@graphql-tools/federation 4.4.2 → 4.4.3-alpha-dbfe579f3fee4fa50a3b0c9610b0f7e3e9760527

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/CHANGELOG.md CHANGED
@@ -1,5 +1,12 @@
1
1
  # @graphql-tools/federation
2
2
 
3
+ ## 4.4.3-alpha-dbfe579f3fee4fa50a3b0c9610b0f7e3e9760527
4
+ ### Patch Changes
5
+
6
+
7
+
8
+ - [#2346](https://github.com/graphql-hive/gateway/pull/2346) [`16fd346`](https://github.com/graphql-hive/gateway/commit/16fd346a18fd77e1094fe4ac2f7a6c2d8923bd68) Thanks [@copilot-swe-agent](https://github.com/apps/copilot-swe-agent)! - Enable the `requires-with-argument-conflict` federation audit compatibility test and fix stitching behavior for conflicting `@requires` argument selections on computed fields by isolating conflict groups into separate subschema configs.
9
+
3
10
  ## 4.4.2
4
11
  ### Patch Changes
5
12
 
package/dist/index.cjs CHANGED
@@ -1272,14 +1272,15 @@ function getStitchingOptionsFromSupergraphSdl(opts) {
1272
1272
  const mergeConfig = {};
1273
1273
  const typeNameKeyMap = typeNameKeysBySubgraphMap.get(subgraphName);
1274
1274
  const unionTypeNodes = [];
1275
+ const pendingConflictSubschemaConfigs = [];
1275
1276
  if (typeNameKeyMap) {
1276
1277
  const typeNameFieldsKeyMap = typeNameFieldsKeyBySubgraphMap.get(subgraphName);
1277
1278
  for (const [typeName, keys] of typeNameKeyMap) {
1278
- let getMergedTypeConfigFromKey2 = function(key) {
1279
+ let getMergedTypeConfigFromKey2 = function(key, keysExtraKeys = extraKeys) {
1279
1280
  return {
1280
1281
  selectionSet: `{ ${key} }`,
1281
1282
  argsFromKeys: getArgsFromKeysForFederation,
1282
- key: getKeyFnForFederation(typeName, [key, ...extraKeys]),
1283
+ key: getKeyFnForFederation(typeName, [key, ...keysExtraKeys]),
1283
1284
  fieldName: `_entities`,
1284
1285
  dataLoaderOptions: {
1285
1286
  cacheKeyFn: getCacheKeyFnFromKey(key),
@@ -1291,38 +1292,96 @@ function getStitchingOptionsFromSupergraphSdl(opts) {
1291
1292
  const fieldsKeyMap = typeNameFieldsKeyMap?.get(typeName);
1292
1293
  const extraKeys = /* @__PURE__ */ new Set();
1293
1294
  if (fieldsKeyMap) {
1294
- const fieldsConfig = mergedTypeConfig.fields = {};
1295
+ let aliasFieldsWithArgs2 = function(selectionSetNode) {
1296
+ for (const selection of selectionSetNode.selections) {
1297
+ if (selection.kind === graphql.Kind.FIELD && selection.arguments?.length) {
1298
+ const argsHash = selection.arguments.map(
1299
+ (arg) => arg.name.value + // TODO: slow? faster hash?
1300
+ memoizedASTPrint(arg.value).replace(
1301
+ /[^a-zA-Z0-9]/g,
1302
+ ""
1303
+ )
1304
+ ).join("");
1305
+ selection.alias = {
1306
+ kind: graphql.Kind.NAME,
1307
+ value: "_" + selection.name.value + "_" + argsHash
1308
+ };
1309
+ }
1310
+ if ("selectionSet" in selection && selection.selectionSet) {
1311
+ aliasFieldsWithArgs2(selection.selectionSet);
1312
+ }
1313
+ }
1314
+ };
1315
+ const mainFieldsConfig = mergedTypeConfig.fields = {};
1316
+ const groups = [
1317
+ {
1318
+ extraKeys,
1319
+ fieldsConfig: mainFieldsConfig,
1320
+ aliasedFields: /* @__PURE__ */ new Map()
1321
+ }
1322
+ ];
1295
1323
  for (const [fieldName, fieldNameKey] of fieldsKeyMap) {
1296
1324
  const selectionSetNode = utils.parseSelectionSet(`{${fieldNameKey}}`);
1297
- (function aliasFieldsWithArgs(selectionSetNode2) {
1298
- for (const selection of selectionSetNode2.selections) {
1299
- if (selection.kind === graphql.Kind.FIELD && selection.arguments?.length) {
1300
- const argsHash = selection.arguments.map(
1301
- (arg) => arg.name.value + // TODO: slow? faster hash?
1302
- memoizedASTPrint(arg.value).replace(
1303
- /[^a-zA-Z0-9]/g,
1304
- ""
1305
- )
1306
- ).join("");
1307
- selection.alias = {
1308
- kind: graphql.Kind.NAME,
1309
- value: "_" + selection.name.value + "_" + argsHash
1310
- };
1311
- }
1312
- if ("selectionSet" in selection && selection.selectionSet) {
1313
- aliasFieldsWithArgs(selection.selectionSet);
1314
- }
1315
- }
1316
- })(selectionSetNode);
1325
+ aliasFieldsWithArgs2(selectionSetNode);
1317
1326
  const selectionSet = graphql.print(selectionSetNode).replaceAll(/\n/g, " ").replaceAll(/\s+/g, " ");
1318
- extraKeys.add(
1327
+ const extraKey = (
1319
1328
  // remove first and last characters (curly braces)
1320
1329
  selectionSet.slice(1, -1)
1321
1330
  );
1322
- fieldsConfig[fieldName] = {
1331
+ const fieldAliasedNames = /* @__PURE__ */ new Map();
1332
+ for (const sel of selectionSetNode.selections) {
1333
+ if (sel.kind === graphql.Kind.FIELD && sel.alias) {
1334
+ fieldAliasedNames.set(sel.name.value, sel.alias.value);
1335
+ }
1336
+ }
1337
+ let targetGroup;
1338
+ for (const group of groups) {
1339
+ let hasConflict = false;
1340
+ for (const [origName, aliasName] of fieldAliasedNames) {
1341
+ const existingAlias = group.aliasedFields.get(origName);
1342
+ if (existingAlias !== void 0 && existingAlias !== aliasName) {
1343
+ hasConflict = true;
1344
+ break;
1345
+ }
1346
+ }
1347
+ if (!hasConflict) {
1348
+ targetGroup = group;
1349
+ break;
1350
+ }
1351
+ }
1352
+ if (!targetGroup) {
1353
+ const newExtraKeys = /* @__PURE__ */ new Set();
1354
+ const newFieldsConfig = {};
1355
+ targetGroup = {
1356
+ extraKeys: newExtraKeys,
1357
+ fieldsConfig: newFieldsConfig,
1358
+ aliasedFields: /* @__PURE__ */ new Map()
1359
+ };
1360
+ groups.push(targetGroup);
1361
+ }
1362
+ targetGroup.extraKeys.add(extraKey);
1363
+ targetGroup.fieldsConfig[fieldName] = {
1323
1364
  selectionSet,
1324
1365
  computed: true
1325
1366
  };
1367
+ for (const [origName, aliasName] of fieldAliasedNames) {
1368
+ targetGroup.aliasedFields.set(origName, aliasName);
1369
+ }
1370
+ }
1371
+ for (const group of groups.slice(1)) {
1372
+ const additionalMergeTypeConfig = {
1373
+ fields: group.fieldsConfig
1374
+ };
1375
+ if (typeNameCanonicalMap.get(typeName) === subgraphName) {
1376
+ additionalMergeTypeConfig.canonical = true;
1377
+ }
1378
+ pendingConflictSubschemaConfigs.push({
1379
+ typeName,
1380
+ // Store closure-captured values for later SubschemaConfig creation
1381
+ // by borrowing getMergedTypeConfigFromKey with the group's extraKeys.
1382
+ mergeTypeConfig: additionalMergeTypeConfig,
1383
+ groupExtraKeys: group.extraKeys
1384
+ });
1326
1385
  }
1327
1386
  }
1328
1387
  if (typeNameCanonicalMap.get(typeName) === subgraphName) {
@@ -1341,6 +1400,21 @@ function getStitchingOptionsFromSupergraphSdl(opts) {
1341
1400
  );
1342
1401
  mergedTypeConfig.entryPoints = entryPoints;
1343
1402
  }
1403
+ for (const pending of pendingConflictSubschemaConfigs) {
1404
+ if (pending.typeName === typeName && !("selectionSet" in pending.mergeTypeConfig) && !("entryPoints" in pending.mergeTypeConfig)) {
1405
+ const groupExtraKeys = pending.groupExtraKeys;
1406
+ if (keysArr.length === 1 && keysArr[0]) {
1407
+ Object.assign(
1408
+ pending.mergeTypeConfig,
1409
+ getMergedTypeConfigFromKey2(keysArr[0], groupExtraKeys)
1410
+ );
1411
+ } else if (keysArr.length > 1) {
1412
+ pending.mergeTypeConfig.entryPoints = keysArr.map(
1413
+ (key) => getMergedTypeConfigFromKey2(key, groupExtraKeys)
1414
+ );
1415
+ }
1416
+ }
1417
+ }
1344
1418
  unionTypeNodes.push({
1345
1419
  kind: graphql.Kind.NAMED_TYPE,
1346
1420
  name: {
@@ -1731,10 +1805,50 @@ function getStitchingOptionsFromSupergraphSdl(opts) {
1731
1805
  }
1732
1806
  }
1733
1807
  }
1808
+ let mainSchema = schema;
1809
+ const additionalGroupFieldsByType = /* @__PURE__ */ new Map();
1810
+ for (const { typeName, mergeTypeConfig } of pendingConflictSubschemaConfigs) {
1811
+ for (const [fieldName, fieldConfig] of Object.entries(
1812
+ mergeTypeConfig.fields ?? {}
1813
+ )) {
1814
+ if (!fieldConfig?.computed) continue;
1815
+ let set = additionalGroupFieldsByType.get(typeName);
1816
+ if (!set) {
1817
+ set = /* @__PURE__ */ new Set();
1818
+ additionalGroupFieldsByType.set(typeName, set);
1819
+ }
1820
+ set.add(fieldName);
1821
+ }
1822
+ }
1823
+ if (additionalGroupFieldsByType.size > 0) {
1824
+ mainSchema = utils.mapSchema(schema, {
1825
+ [utils.MapperKind.OBJECT_FIELD]: (fieldConfig, fieldName, typeName) => {
1826
+ if (additionalGroupFieldsByType.get(typeName)?.has(fieldName)) {
1827
+ return null;
1828
+ }
1829
+ return fieldConfig;
1830
+ }
1831
+ });
1832
+ }
1833
+ const allComputedFieldsByType = new Map(
1834
+ Array.from(additionalGroupFieldsByType, ([t, s]) => [t, new Set(s)])
1835
+ );
1836
+ for (const [typeName, typeConfig] of Object.entries(mergeConfig)) {
1837
+ if (!typeConfig?.fields) continue;
1838
+ for (const [fieldName, fieldConfig] of Object.entries(typeConfig.fields)) {
1839
+ if (!fieldConfig?.computed) continue;
1840
+ let set = allComputedFieldsByType.get(typeName);
1841
+ if (!set) {
1842
+ set = /* @__PURE__ */ new Set();
1843
+ allComputedFieldsByType.set(typeName, set);
1844
+ }
1845
+ set.add(fieldName);
1846
+ }
1847
+ }
1734
1848
  const subschemaConfig = {
1735
1849
  name: subgraphName,
1736
1850
  endpoint,
1737
- schema,
1851
+ schema: mainSchema,
1738
1852
  executor: executor$1,
1739
1853
  merge: mergeConfig,
1740
1854
  transforms,
@@ -1742,6 +1856,33 @@ function getStitchingOptionsFromSupergraphSdl(opts) {
1742
1856
  batchingOptions: opts.batchingOptions
1743
1857
  };
1744
1858
  subschemas.push(subschemaConfig);
1859
+ for (const { typeName, mergeTypeConfig } of pendingConflictSubschemaConfigs) {
1860
+ const groupOwnFields = new Set(
1861
+ Object.entries(mergeTypeConfig.fields ?? {}).filter(([, fc]) => fc?.computed).map(([fn]) => fn)
1862
+ );
1863
+ const allComputedForType = allComputedFieldsByType.get(typeName) ?? /* @__PURE__ */ new Set();
1864
+ const fieldsToRemove = new Set(
1865
+ [...allComputedForType].filter((f) => !groupOwnFields.has(f))
1866
+ );
1867
+ const groupSchema = fieldsToRemove.size > 0 ? utils.mapSchema(schema, {
1868
+ [utils.MapperKind.OBJECT_FIELD]: (fieldConfig, fieldName, type) => {
1869
+ if (type === typeName && fieldsToRemove.has(fieldName)) {
1870
+ return null;
1871
+ }
1872
+ return fieldConfig;
1873
+ }
1874
+ }) : schema;
1875
+ subschemas.push({
1876
+ name: subgraphName,
1877
+ endpoint,
1878
+ schema: groupSchema,
1879
+ executor: executor$1,
1880
+ merge: { [typeName]: mergeTypeConfig },
1881
+ transforms,
1882
+ batch: opts.batch,
1883
+ batchingOptions: opts.batchingOptions
1884
+ });
1885
+ }
1745
1886
  }
1746
1887
  const defaultMerger = stitch.getDefaultFieldConfigMerger(true);
1747
1888
  const fieldConfigMerger = function(candidates) {
package/dist/index.js CHANGED
@@ -1270,14 +1270,15 @@ function getStitchingOptionsFromSupergraphSdl(opts) {
1270
1270
  const mergeConfig = {};
1271
1271
  const typeNameKeyMap = typeNameKeysBySubgraphMap.get(subgraphName);
1272
1272
  const unionTypeNodes = [];
1273
+ const pendingConflictSubschemaConfigs = [];
1273
1274
  if (typeNameKeyMap) {
1274
1275
  const typeNameFieldsKeyMap = typeNameFieldsKeyBySubgraphMap.get(subgraphName);
1275
1276
  for (const [typeName, keys] of typeNameKeyMap) {
1276
- let getMergedTypeConfigFromKey2 = function(key) {
1277
+ let getMergedTypeConfigFromKey2 = function(key, keysExtraKeys = extraKeys) {
1277
1278
  return {
1278
1279
  selectionSet: `{ ${key} }`,
1279
1280
  argsFromKeys: getArgsFromKeysForFederation,
1280
- key: getKeyFnForFederation(typeName, [key, ...extraKeys]),
1281
+ key: getKeyFnForFederation(typeName, [key, ...keysExtraKeys]),
1281
1282
  fieldName: `_entities`,
1282
1283
  dataLoaderOptions: {
1283
1284
  cacheKeyFn: getCacheKeyFnFromKey(key),
@@ -1289,38 +1290,96 @@ function getStitchingOptionsFromSupergraphSdl(opts) {
1289
1290
  const fieldsKeyMap = typeNameFieldsKeyMap?.get(typeName);
1290
1291
  const extraKeys = /* @__PURE__ */ new Set();
1291
1292
  if (fieldsKeyMap) {
1292
- const fieldsConfig = mergedTypeConfig.fields = {};
1293
+ let aliasFieldsWithArgs2 = function(selectionSetNode) {
1294
+ for (const selection of selectionSetNode.selections) {
1295
+ if (selection.kind === Kind.FIELD && selection.arguments?.length) {
1296
+ const argsHash = selection.arguments.map(
1297
+ (arg) => arg.name.value + // TODO: slow? faster hash?
1298
+ memoizedASTPrint(arg.value).replace(
1299
+ /[^a-zA-Z0-9]/g,
1300
+ ""
1301
+ )
1302
+ ).join("");
1303
+ selection.alias = {
1304
+ kind: Kind.NAME,
1305
+ value: "_" + selection.name.value + "_" + argsHash
1306
+ };
1307
+ }
1308
+ if ("selectionSet" in selection && selection.selectionSet) {
1309
+ aliasFieldsWithArgs2(selection.selectionSet);
1310
+ }
1311
+ }
1312
+ };
1313
+ const mainFieldsConfig = mergedTypeConfig.fields = {};
1314
+ const groups = [
1315
+ {
1316
+ extraKeys,
1317
+ fieldsConfig: mainFieldsConfig,
1318
+ aliasedFields: /* @__PURE__ */ new Map()
1319
+ }
1320
+ ];
1293
1321
  for (const [fieldName, fieldNameKey] of fieldsKeyMap) {
1294
1322
  const selectionSetNode = parseSelectionSet(`{${fieldNameKey}}`);
1295
- (function aliasFieldsWithArgs(selectionSetNode2) {
1296
- for (const selection of selectionSetNode2.selections) {
1297
- if (selection.kind === Kind.FIELD && selection.arguments?.length) {
1298
- const argsHash = selection.arguments.map(
1299
- (arg) => arg.name.value + // TODO: slow? faster hash?
1300
- memoizedASTPrint(arg.value).replace(
1301
- /[^a-zA-Z0-9]/g,
1302
- ""
1303
- )
1304
- ).join("");
1305
- selection.alias = {
1306
- kind: Kind.NAME,
1307
- value: "_" + selection.name.value + "_" + argsHash
1308
- };
1309
- }
1310
- if ("selectionSet" in selection && selection.selectionSet) {
1311
- aliasFieldsWithArgs(selection.selectionSet);
1312
- }
1313
- }
1314
- })(selectionSetNode);
1323
+ aliasFieldsWithArgs2(selectionSetNode);
1315
1324
  const selectionSet = print(selectionSetNode).replaceAll(/\n/g, " ").replaceAll(/\s+/g, " ");
1316
- extraKeys.add(
1325
+ const extraKey = (
1317
1326
  // remove first and last characters (curly braces)
1318
1327
  selectionSet.slice(1, -1)
1319
1328
  );
1320
- fieldsConfig[fieldName] = {
1329
+ const fieldAliasedNames = /* @__PURE__ */ new Map();
1330
+ for (const sel of selectionSetNode.selections) {
1331
+ if (sel.kind === Kind.FIELD && sel.alias) {
1332
+ fieldAliasedNames.set(sel.name.value, sel.alias.value);
1333
+ }
1334
+ }
1335
+ let targetGroup;
1336
+ for (const group of groups) {
1337
+ let hasConflict = false;
1338
+ for (const [origName, aliasName] of fieldAliasedNames) {
1339
+ const existingAlias = group.aliasedFields.get(origName);
1340
+ if (existingAlias !== void 0 && existingAlias !== aliasName) {
1341
+ hasConflict = true;
1342
+ break;
1343
+ }
1344
+ }
1345
+ if (!hasConflict) {
1346
+ targetGroup = group;
1347
+ break;
1348
+ }
1349
+ }
1350
+ if (!targetGroup) {
1351
+ const newExtraKeys = /* @__PURE__ */ new Set();
1352
+ const newFieldsConfig = {};
1353
+ targetGroup = {
1354
+ extraKeys: newExtraKeys,
1355
+ fieldsConfig: newFieldsConfig,
1356
+ aliasedFields: /* @__PURE__ */ new Map()
1357
+ };
1358
+ groups.push(targetGroup);
1359
+ }
1360
+ targetGroup.extraKeys.add(extraKey);
1361
+ targetGroup.fieldsConfig[fieldName] = {
1321
1362
  selectionSet,
1322
1363
  computed: true
1323
1364
  };
1365
+ for (const [origName, aliasName] of fieldAliasedNames) {
1366
+ targetGroup.aliasedFields.set(origName, aliasName);
1367
+ }
1368
+ }
1369
+ for (const group of groups.slice(1)) {
1370
+ const additionalMergeTypeConfig = {
1371
+ fields: group.fieldsConfig
1372
+ };
1373
+ if (typeNameCanonicalMap.get(typeName) === subgraphName) {
1374
+ additionalMergeTypeConfig.canonical = true;
1375
+ }
1376
+ pendingConflictSubschemaConfigs.push({
1377
+ typeName,
1378
+ // Store closure-captured values for later SubschemaConfig creation
1379
+ // by borrowing getMergedTypeConfigFromKey with the group's extraKeys.
1380
+ mergeTypeConfig: additionalMergeTypeConfig,
1381
+ groupExtraKeys: group.extraKeys
1382
+ });
1324
1383
  }
1325
1384
  }
1326
1385
  if (typeNameCanonicalMap.get(typeName) === subgraphName) {
@@ -1339,6 +1398,21 @@ function getStitchingOptionsFromSupergraphSdl(opts) {
1339
1398
  );
1340
1399
  mergedTypeConfig.entryPoints = entryPoints;
1341
1400
  }
1401
+ for (const pending of pendingConflictSubschemaConfigs) {
1402
+ if (pending.typeName === typeName && !("selectionSet" in pending.mergeTypeConfig) && !("entryPoints" in pending.mergeTypeConfig)) {
1403
+ const groupExtraKeys = pending.groupExtraKeys;
1404
+ if (keysArr.length === 1 && keysArr[0]) {
1405
+ Object.assign(
1406
+ pending.mergeTypeConfig,
1407
+ getMergedTypeConfigFromKey2(keysArr[0], groupExtraKeys)
1408
+ );
1409
+ } else if (keysArr.length > 1) {
1410
+ pending.mergeTypeConfig.entryPoints = keysArr.map(
1411
+ (key) => getMergedTypeConfigFromKey2(key, groupExtraKeys)
1412
+ );
1413
+ }
1414
+ }
1415
+ }
1342
1416
  unionTypeNodes.push({
1343
1417
  kind: Kind.NAMED_TYPE,
1344
1418
  name: {
@@ -1729,10 +1803,50 @@ function getStitchingOptionsFromSupergraphSdl(opts) {
1729
1803
  }
1730
1804
  }
1731
1805
  }
1806
+ let mainSchema = schema;
1807
+ const additionalGroupFieldsByType = /* @__PURE__ */ new Map();
1808
+ for (const { typeName, mergeTypeConfig } of pendingConflictSubschemaConfigs) {
1809
+ for (const [fieldName, fieldConfig] of Object.entries(
1810
+ mergeTypeConfig.fields ?? {}
1811
+ )) {
1812
+ if (!fieldConfig?.computed) continue;
1813
+ let set = additionalGroupFieldsByType.get(typeName);
1814
+ if (!set) {
1815
+ set = /* @__PURE__ */ new Set();
1816
+ additionalGroupFieldsByType.set(typeName, set);
1817
+ }
1818
+ set.add(fieldName);
1819
+ }
1820
+ }
1821
+ if (additionalGroupFieldsByType.size > 0) {
1822
+ mainSchema = mapSchema(schema, {
1823
+ [MapperKind.OBJECT_FIELD]: (fieldConfig, fieldName, typeName) => {
1824
+ if (additionalGroupFieldsByType.get(typeName)?.has(fieldName)) {
1825
+ return null;
1826
+ }
1827
+ return fieldConfig;
1828
+ }
1829
+ });
1830
+ }
1831
+ const allComputedFieldsByType = new Map(
1832
+ Array.from(additionalGroupFieldsByType, ([t, s]) => [t, new Set(s)])
1833
+ );
1834
+ for (const [typeName, typeConfig] of Object.entries(mergeConfig)) {
1835
+ if (!typeConfig?.fields) continue;
1836
+ for (const [fieldName, fieldConfig] of Object.entries(typeConfig.fields)) {
1837
+ if (!fieldConfig?.computed) continue;
1838
+ let set = allComputedFieldsByType.get(typeName);
1839
+ if (!set) {
1840
+ set = /* @__PURE__ */ new Set();
1841
+ allComputedFieldsByType.set(typeName, set);
1842
+ }
1843
+ set.add(fieldName);
1844
+ }
1845
+ }
1732
1846
  const subschemaConfig = {
1733
1847
  name: subgraphName,
1734
1848
  endpoint,
1735
- schema,
1849
+ schema: mainSchema,
1736
1850
  executor,
1737
1851
  merge: mergeConfig,
1738
1852
  transforms,
@@ -1740,6 +1854,33 @@ function getStitchingOptionsFromSupergraphSdl(opts) {
1740
1854
  batchingOptions: opts.batchingOptions
1741
1855
  };
1742
1856
  subschemas.push(subschemaConfig);
1857
+ for (const { typeName, mergeTypeConfig } of pendingConflictSubschemaConfigs) {
1858
+ const groupOwnFields = new Set(
1859
+ Object.entries(mergeTypeConfig.fields ?? {}).filter(([, fc]) => fc?.computed).map(([fn]) => fn)
1860
+ );
1861
+ const allComputedForType = allComputedFieldsByType.get(typeName) ?? /* @__PURE__ */ new Set();
1862
+ const fieldsToRemove = new Set(
1863
+ [...allComputedForType].filter((f) => !groupOwnFields.has(f))
1864
+ );
1865
+ const groupSchema = fieldsToRemove.size > 0 ? mapSchema(schema, {
1866
+ [MapperKind.OBJECT_FIELD]: (fieldConfig, fieldName, type) => {
1867
+ if (type === typeName && fieldsToRemove.has(fieldName)) {
1868
+ return null;
1869
+ }
1870
+ return fieldConfig;
1871
+ }
1872
+ }) : schema;
1873
+ subschemas.push({
1874
+ name: subgraphName,
1875
+ endpoint,
1876
+ schema: groupSchema,
1877
+ executor,
1878
+ merge: { [typeName]: mergeTypeConfig },
1879
+ transforms,
1880
+ batch: opts.batch,
1881
+ batchingOptions: opts.batchingOptions
1882
+ });
1883
+ }
1743
1884
  }
1744
1885
  const defaultMerger = getDefaultFieldConfigMerger(true);
1745
1886
  const fieldConfigMerger = function(candidates) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@graphql-tools/federation",
3
- "version": "4.4.2",
3
+ "version": "4.4.3-alpha-dbfe579f3fee4fa50a3b0c9610b0f7e3e9760527",
4
4
  "type": "module",
5
5
  "description": "Useful tools to create and manipulate GraphQL schemas.",
6
6
  "repository": {