@graphql-tools/delegate 12.2.1 → 12.3.0-rc-4cd028a0e0c6072a637a51299090d5a8daab75af

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,77 @@
1
1
  # @graphql-tools/delegate
2
2
 
3
+ ## 12.3.0-rc-4cd028a0e0c6072a637a51299090d5a8daab75af
4
+ ### Minor Changes
5
+
6
+
7
+
8
+ - [#2672](https://github.com/graphql-hive/gateway/pull/2672) [`befdb8e`](https://github.com/graphql-hive/gateway/commit/befdb8e3e352650c9f6c4e5fbeadfcf3615ee6ae) Thanks [@ardatan](https://github.com/ardatan)! - Support `@defer` / `@stream` incremental delivery within schema stitching.
9
+
10
+ **Gateway-owned `@defer` (default):** deferred selections are omitted from subgraph requests (only `@requires` / key dependencies are kept), so nested `@defer` can flush before slow fields resolve. Missing fields are filled later via type-merging or source resolvers.
11
+
12
+ **Subgraph-forwarded `@defer`:** set `defer: true` on a `SubschemaConfig` (or `defer: true` on `getStitchedSchemaFromSupergraphSdl`) to forward `@defer` to that subgraph and merge incremental patches via `IncrementalReceiver`. With `batch: true` and `batchingOptions.defer` (or `subschema.defer`), multi-request batches wrap each root selection in `@defer` for subgraph compatibility; results are still collected before DataLoader waiters resolve. Single-request batches pass the AsyncIterable through so the initial payload can flush before deferred patches arrive.
13
+
14
+ **Hive Gateway config:** extend `deferStream` instead of a separate flag:
15
+
16
+ ```ts
17
+ deferStream: true // client-facing only (gateway-owned omit)
18
+ deferStream: { subgraph: true } // also forward @defer to every subgraph
19
+ deferStream: { subgraph: { users: true, '*': false } } // per-subgraph
20
+ ```
21
+
22
+ `@graphql-tools/executor-http` adds `mergeIncremental` (default `true`: legacy growing snapshots). Set `mergeIncremental: false` to yield raw multipart parts like the default schema executor. Hive Gateway's `@graphql-mesh/transport-http` always uses passthrough (`mergeIncremental: false`).
23
+
24
+ `IncrementalReceiver` prefers raw patches and cheaply tolerates accumulated snapshots (only fills missing keys). The HTTP executor preserves `hasNext` in accumulate mode.
25
+
26
+ `@stream` continues to be forwarded on field directives as before. List streaming in `@graphql-tools/delegate` uses a plain async generator (no `@repeaterjs/repeater` dependency).
27
+
28
+ Hive Router runtime does not plan incremental delivery yet; `deferStream.subgraph` applies to the stitching federation path.
29
+
30
+ ### Patch Changes
31
+
32
+
33
+
34
+ - [#2671](https://github.com/graphql-hive/gateway/pull/2671) [`cd30482`](https://github.com/graphql-hive/gateway/commit/cd30482174173564e7a292f36b8dd12cc7cfab59) Thanks [@ardatan](https://github.com/ardatan)! - Fix type merging for unions queried with inline fragments ([graphql-tools#4965](https://github.com/ardatan/graphql-tools/pull/4965) / [#4966](https://github.com/ardatan/graphql-tools/issues/4966)).
35
+
36
+ Typical setup: one subschema returns a stub member (`StubMajor { id }`) while another resolves the real union members via `@merge`:
37
+
38
+ ```graphql
39
+ # students
40
+ union Major = StubMajor
41
+ type StubMajor { id: String! }
42
+
43
+ # majors
44
+ type Query {
45
+ major(id: String!): Major @merge(keyField: "id")
46
+ }
47
+ union Major = MajorSuccess | MajorError
48
+ ```
49
+
50
+ Client query:
51
+
52
+ ```graphql
53
+ major {
54
+ ... on MajorSuccess { id name }
55
+ ... on MajorError { id code }
56
+ }
57
+ ```
58
+
59
+ Three problems stacked:
60
+
61
+ 1. `@merge` on a union only registered concrete members (`MajorSuccess` / `MajorError`), not `Major` itself, so a `StubMajor` result never triggered merge.
62
+ 2. `MergedTypeInfo` was not built for union types, and planners assumed object/interface `getFields()`.
63
+ 3. Expanding a bare merge-key field (`id`) on a union into `... on StubMajor { id }` returned an **array** from the FIELD visitor; graphql-js `visit` nests that array as one selection instead of splicing it, so execution ignored the fragment and the merge key was never queried (`major(id: $id)` ran with empty variables).
64
+
65
+ Fixes:
66
+
67
+ - Register the abstract union/interface name for `@merge` as well as concrete members.
68
+ - Build merge info for unions; treat unions as field-less so the abstract planner re-fetches via inline fragments.
69
+ - Flatten nested selection arrays after union field expansion so stub keys are actually requested.
70
+
71
+ This goes beyond the [schema-extension workaround](https://github.com/ardatan/graphql-tools/issues/4966#issuecomment-1670713991) discussed on the issue.
72
+ - Updated dependencies [[`befdb8e`](https://github.com/graphql-hive/gateway/commit/befdb8e3e352650c9f6c4e5fbeadfcf3615ee6ae)]:
73
+ - @graphql-tools/batch-execute@10.3.0-rc-4cd028a0e0c6072a637a51299090d5a8daab75af
74
+
3
75
  ## 12.2.1
4
76
  ### Patch Changes
5
77