@graphql-tools/delegate 12.0.14 → 12.0.16

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,29 @@
1
1
  # @graphql-tools/delegate
2
2
 
3
+ ## 12.0.16
4
+ ### Patch Changes
5
+
6
+
7
+
8
+ - [#2320](https://github.com/graphql-hive/gateway/pull/2320) [`deafdc0`](https://github.com/graphql-hive/gateway/commit/deafdc00e388ed195c2cdf77e98cd19e7d496d48) Thanks [@copilot-swe-agent](https://github.com/apps/copilot-swe-agent)! - Fix `@stream` directive not working for federated subgraphs with non-null scalar list return types.
9
+
10
+ Two bugs were addressed in `delegateRequest`:
11
+
12
+ 1. `isListType` was called without first unwrapping `NonNull`, so a field typed `[String!]!` (a `NonNull(List(...))`) was not recognised as a list. The fix wraps the check with `getNullableType()`.
13
+
14
+ 2. Deduplication of already-pushed stream items used a `WeakSet`, which throws a `TypeError` for primitive values (strings, numbers, etc.). This was replaced with an integer index counter that works for both object and primitive list items.
15
+
16
+ ## 12.0.15
17
+ ### Patch Changes
18
+
19
+
20
+
21
+ - [#2306](https://github.com/graphql-hive/gateway/pull/2306) [`7171b46`](https://github.com/graphql-hive/gateway/commit/7171b46546a8e60776f70d18d14dd6fa19d5649f) Thanks [@copilot-swe-agent](https://github.com/apps/copilot-swe-agent)! - Fix incorrect error path when delegating a single type to a list type in a subschema.
22
+
23
+ When using schema stitching with type merging (e.g., a supergraph `book` field delegating to a subschema `books` list field via batch delegation), errors from the subschema now correctly report the path as seen in the supergraph (e.g., `['book', 'title']`) instead of including an unexpected array index (e.g., `['book', 0, 'title']`).
24
+
25
+ Also ensures `onLocatedError` is passed through in all branches of `getDelegationContext`.
26
+
3
27
  ## 12.0.14
4
28
  ### Patch Changes
5
29
 
package/dist/index.cjs CHANGED
@@ -2647,9 +2647,9 @@ function delegateRequest(options) {
2647
2647
  () => getExecutor(delegationContext)(processedRequest),
2648
2648
  function handleExecutorResult(executorResult) {
2649
2649
  if (utils.isAsyncIterable(executorResult)) {
2650
- if (delegationContext.operation === "query" && graphql.isListType(delegationContext.returnType)) {
2650
+ if (delegationContext.operation === "query" && graphql.isListType(graphql.getNullableType(delegationContext.returnType))) {
2651
2651
  return new repeater.Repeater(async (push, stop) => {
2652
- const pushed = /* @__PURE__ */ new WeakSet();
2652
+ let pushedCount = 0;
2653
2653
  let stopped = false;
2654
2654
  stop.finally(() => {
2655
2655
  stopped = true;
@@ -2681,15 +2681,12 @@ function delegateRequest(options) {
2681
2681
  }
2682
2682
  const transformedResult = await transformer.transformResult(result);
2683
2683
  if (Array.isArray(transformedResult)) {
2684
- for (const individualResult$ of transformedResult) {
2684
+ for (let i = pushedCount; i < transformedResult.length; i++) {
2685
2685
  if (stopped) {
2686
2686
  break;
2687
2687
  }
2688
- const individualResult = await individualResult$;
2689
- if (!pushed.has(individualResult)) {
2690
- pushed.add(individualResult);
2691
- await push(individualResult);
2692
- }
2688
+ await push(await transformedResult[i]);
2689
+ pushedCount = i + 1;
2693
2690
  }
2694
2691
  } else {
2695
2692
  await push(await transformedResult);
@@ -2765,7 +2762,9 @@ function getDelegationContext({
2765
2762
  ),
2766
2763
  transforms,
2767
2764
  transformedSchema: transformedSchema ?? subschemaOrSubschemaConfig,
2768
- skipTypeMerging
2765
+ skipTypeMerging,
2766
+ onLocatedError,
2767
+ args
2769
2768
  };
2770
2769
  }
2771
2770
  function validateRequest(delegationContext, document) {
package/dist/index.js CHANGED
@@ -2647,9 +2647,9 @@ function delegateRequest(options) {
2647
2647
  () => getExecutor(delegationContext)(processedRequest),
2648
2648
  function handleExecutorResult(executorResult) {
2649
2649
  if (isAsyncIterable(executorResult)) {
2650
- if (delegationContext.operation === "query" && isListType(delegationContext.returnType)) {
2650
+ if (delegationContext.operation === "query" && isListType(getNullableType(delegationContext.returnType))) {
2651
2651
  return new Repeater(async (push, stop) => {
2652
- const pushed = /* @__PURE__ */ new WeakSet();
2652
+ let pushedCount = 0;
2653
2653
  let stopped = false;
2654
2654
  stop.finally(() => {
2655
2655
  stopped = true;
@@ -2681,15 +2681,12 @@ function delegateRequest(options) {
2681
2681
  }
2682
2682
  const transformedResult = await transformer.transformResult(result);
2683
2683
  if (Array.isArray(transformedResult)) {
2684
- for (const individualResult$ of transformedResult) {
2684
+ for (let i = pushedCount; i < transformedResult.length; i++) {
2685
2685
  if (stopped) {
2686
2686
  break;
2687
2687
  }
2688
- const individualResult = await individualResult$;
2689
- if (!pushed.has(individualResult)) {
2690
- pushed.add(individualResult);
2691
- await push(individualResult);
2692
- }
2688
+ await push(await transformedResult[i]);
2689
+ pushedCount = i + 1;
2693
2690
  }
2694
2691
  } else {
2695
2692
  await push(await transformedResult);
@@ -2765,7 +2762,9 @@ function getDelegationContext({
2765
2762
  ),
2766
2763
  transforms,
2767
2764
  transformedSchema: transformedSchema ?? subschemaOrSubschemaConfig,
2768
- skipTypeMerging
2765
+ skipTypeMerging,
2766
+ onLocatedError,
2767
+ args
2769
2768
  };
2770
2769
  }
2771
2770
  function validateRequest(delegationContext, document) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@graphql-tools/delegate",
3
- "version": "12.0.14",
3
+ "version": "12.0.16",
4
4
  "type": "module",
5
5
  "description": "A set of utils for faster development of GraphQL tools",
6
6
  "repository": {