@graphql-tools/federation 3.2.3-rc-434d43c1d0e90a737a8024d58e77492c84c1f777 → 3.2.3

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,6 +1,6 @@
1
1
  # @graphql-tools/federation
2
2
 
3
- ## 3.2.3-rc-434d43c1d0e90a737a8024d58e77492c84c1f777
3
+ ## 3.2.3
4
4
 
5
5
  ### Patch Changes
6
6
 
@@ -8,13 +8,15 @@
8
8
 
9
9
  - Updated dependency [`@whatwg-node/fetch@^0.10.8` ↗︎](https://www.npmjs.com/package/@whatwg-node/fetch/v/0.10.8) (from `^0.10.6`, in `dependencies`)
10
10
 
11
+ - [#1187](https://github.com/graphql-hive/gateway/pull/1187) [`85d7c95`](https://github.com/graphql-hive/gateway/commit/85d7c95cfe90773daf7680f2308ff4f52f0f7fa9) Thanks [@enisdenjo](https://github.com/enisdenjo)! - Handle nested keys with arguments
12
+
11
13
  - [#1136](https://github.com/graphql-hive/gateway/pull/1136) [`511ba36`](https://github.com/graphql-hive/gateway/commit/511ba36d9c8b81f83cf4cb37c03c9fbb9c5c9c9d) Thanks [@ardatan](https://github.com/ardatan)! - Handle errors on non-nullable fields in shared root fields correctly
12
14
 
13
15
  - Updated dependencies [[`54beb7a`](https://github.com/graphql-hive/gateway/commit/54beb7acde7558eee81ec0e20c123717865b8e18), [`4a80de1`](https://github.com/graphql-hive/gateway/commit/4a80de1a2884dc42a5f09202b6215c3e6780efc4)]:
14
- - @graphql-tools/executor-http@2.0.2-rc-434d43c1d0e90a737a8024d58e77492c84c1f777
15
- - @graphql-tools/wrap@10.1.0-rc-434d43c1d0e90a737a8024d58e77492c84c1f777
16
- - @graphql-tools/stitch@9.4.24-rc-434d43c1d0e90a737a8024d58e77492c84c1f777
17
- - @graphql-tools/delegate@10.2.19-rc-434d43c1d0e90a737a8024d58e77492c84c1f777
16
+ - @graphql-tools/executor-http@2.0.2
17
+ - @graphql-tools/wrap@10.1.0
18
+ - @graphql-tools/stitch@9.4.24
19
+ - @graphql-tools/delegate@10.2.19
18
20
 
19
21
  ## 3.2.2
20
22
 
package/dist/index.cjs CHANGED
@@ -871,10 +871,27 @@ function getStitchingOptionsFromSupergraphSdl(opts) {
871
871
  if (fieldsKeyMap) {
872
872
  const fieldsConfig = mergedTypeConfig.fields = {};
873
873
  for (const [fieldName, fieldNameKey] of fieldsKeyMap) {
874
- const aliasedFieldNameKey = fieldNameKey.includes("(") ? `_${fieldNameKey.split("(")[0]}: ${fieldNameKey}` : fieldNameKey;
875
- extraKeys.add(aliasedFieldNameKey);
874
+ const selectionSetNode = utils.parseSelectionSet(`{${fieldNameKey}}`);
875
+ (function aliasFieldsWithArgs(selectionSetNode2) {
876
+ for (const selection of selectionSetNode2.selections) {
877
+ if (selection.kind === graphql.Kind.FIELD && selection.arguments?.length) {
878
+ selection.alias = {
879
+ kind: graphql.Kind.NAME,
880
+ value: "_" + selection.name.value
881
+ };
882
+ }
883
+ if ("selectionSet" in selection && selection.selectionSet) {
884
+ aliasFieldsWithArgs(selection.selectionSet);
885
+ }
886
+ }
887
+ })(selectionSetNode);
888
+ const selectionSet = graphql.print(selectionSetNode).replaceAll(/\n/g, " ").replaceAll(/\s+/g, " ");
889
+ extraKeys.add(
890
+ // remove first and last characters (curly braces)
891
+ selectionSet.slice(1, -1)
892
+ );
876
893
  fieldsConfig[fieldName] = {
877
- selectionSet: `{ ${aliasedFieldNameKey} }`,
894
+ selectionSet,
878
895
  computed: true
879
896
  };
880
897
  }
package/dist/index.js CHANGED
@@ -7,7 +7,7 @@ import { CRITICAL_ERROR } from '@graphql-tools/executor';
7
7
  import { buildHTTPExecutor } from '@graphql-tools/executor-http';
8
8
  import { getDefaultFieldConfigMerger, ValidationLevel, stitchSchemas, calculateSelectionScore } from '@graphql-tools/stitch';
9
9
  import { isPromise, handleMaybePromise } from '@whatwg-node/promise-helpers';
10
- import { Kind, parse, visit, buildASTSchema, isObjectType, isInterfaceType, isInputObjectType, parseType, print, visitWithTypeInfo } from 'graphql';
10
+ import { Kind, parse, visit, print, buildASTSchema, isObjectType, isInterfaceType, isInputObjectType, parseType, visitWithTypeInfo } from 'graphql';
11
11
 
12
12
  const getArgsFromKeysForFederation = memoize1(
13
13
  function getArgsFromKeysForFederation2(representations) {
@@ -869,10 +869,27 @@ function getStitchingOptionsFromSupergraphSdl(opts) {
869
869
  if (fieldsKeyMap) {
870
870
  const fieldsConfig = mergedTypeConfig.fields = {};
871
871
  for (const [fieldName, fieldNameKey] of fieldsKeyMap) {
872
- const aliasedFieldNameKey = fieldNameKey.includes("(") ? `_${fieldNameKey.split("(")[0]}: ${fieldNameKey}` : fieldNameKey;
873
- extraKeys.add(aliasedFieldNameKey);
872
+ const selectionSetNode = parseSelectionSet(`{${fieldNameKey}}`);
873
+ (function aliasFieldsWithArgs(selectionSetNode2) {
874
+ for (const selection of selectionSetNode2.selections) {
875
+ if (selection.kind === Kind.FIELD && selection.arguments?.length) {
876
+ selection.alias = {
877
+ kind: Kind.NAME,
878
+ value: "_" + selection.name.value
879
+ };
880
+ }
881
+ if ("selectionSet" in selection && selection.selectionSet) {
882
+ aliasFieldsWithArgs(selection.selectionSet);
883
+ }
884
+ }
885
+ })(selectionSetNode);
886
+ const selectionSet = print(selectionSetNode).replaceAll(/\n/g, " ").replaceAll(/\s+/g, " ");
887
+ extraKeys.add(
888
+ // remove first and last characters (curly braces)
889
+ selectionSet.slice(1, -1)
890
+ );
874
891
  fieldsConfig[fieldName] = {
875
- selectionSet: `{ ${aliasedFieldNameKey} }`,
892
+ selectionSet,
876
893
  computed: true
877
894
  };
878
895
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@graphql-tools/federation",
3
- "version": "3.2.3-rc-434d43c1d0e90a737a8024d58e77492c84c1f777",
3
+ "version": "3.2.3",
4
4
  "type": "module",
5
5
  "description": "Useful tools to create and manipulate GraphQL schemas.",
6
6
  "repository": {
@@ -38,14 +38,14 @@
38
38
  "graphql": "^14.0.0 || ^15.0.0 || ^16.0.0 || ^17.0.0"
39
39
  },
40
40
  "dependencies": {
41
- "@graphql-tools/delegate": "10.2.19-rc-434d43c1d0e90a737a8024d58e77492c84c1f777",
41
+ "@graphql-tools/delegate": "^10.2.19",
42
42
  "@graphql-tools/executor": "^1.4.7",
43
- "@graphql-tools/executor-http": "2.0.2-rc-434d43c1d0e90a737a8024d58e77492c84c1f777",
43
+ "@graphql-tools/executor-http": "^2.0.2",
44
44
  "@graphql-tools/merge": "^9.0.12",
45
45
  "@graphql-tools/schema": "^10.0.11",
46
- "@graphql-tools/stitch": "9.4.24-rc-434d43c1d0e90a737a8024d58e77492c84c1f777",
46
+ "@graphql-tools/stitch": "^9.4.24",
47
47
  "@graphql-tools/utils": "^10.8.1",
48
- "@graphql-tools/wrap": "10.1.0-rc-434d43c1d0e90a737a8024d58e77492c84c1f777",
48
+ "@graphql-tools/wrap": "^10.1.0",
49
49
  "@graphql-yoga/typed-event-target": "^3.0.1",
50
50
  "@whatwg-node/disposablestack": "^0.0.6",
51
51
  "@whatwg-node/events": "^0.1.2",