Packages

@graphql-tools/stitch

10.4.4 · 12 Nov 2026MIT546k / weekRepositorynpmAtom feed

Your version

10.4.0

23 Oct 2026Where it was published

10.4.4 is the newest release of 10.x.

Summary· from the note as AI read it

No actionNothing to change: 1 new, 3 fixed.

New

  • Support @defer / @stream incremental delivery within schema stitching.

In short

1 new3 fixed4 internal

Release note

The section about @graphql-tools/stitch of a note shared by several packages.

@graphql-tools/stitch@10.4.0

Minor Changes

  • Support @defer / @stream incremental delivery within schema stitching.

    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.

    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.

    Hive Gateway config: extend deferStream instead of a separate flag:

    deferStream: true // client-facing only (gateway-owned omit)
    deferStream: { subgraph: true } // also forward @defer to every subgraph
    deferStream: { subgraph: { users: true, '*': false } } // per-subgraph

    @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).

    IncrementalReceiver prefers raw patches and cheaply tolerates accumulated snapshots (only fills missing keys). The HTTP executor preserves hasNext in accumulate mode.

    @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).

    Hive Router runtime does not plan incremental delivery yet; deferStream.subgraph applies to the stitching federation path.

Patch Changes

  • Allow @merge without keyArg when the resolver takes zero arguments, and make keyless type merges work when the initial subschema cannot satisfy the requested fields (graphql-tools#4337).

    Previously the validator rejected @merge on zero-arg fields (args.length !== 1). It now allows zero or one argument and only errors when there are multiple args without keyArg / argsExpr.

    Separately, keyless merges such as:

    merge: {
      Stats: {
        fieldName: 'stats',
        args: () => ({}),
      },
    }

    had no key selectionSet. When the subschema that owned Query.stats did not have the requested fields (for example querying only totalChirps while that field lived on the other subschema), finalizeGatewayRequest stripped the empty nested selection and failed with "The request must contain at least one operation."

    For merged types that have resolvers but no key selectionSet, stitching now injects __typename into fieldNodesByType so a stub object remains and type merging can fill the remaining fields. This matches the partial-field failure called out in this discussion. Keyed merges (selectionSet: '{ id }') are unchanged.

  • Merged type resolvers now preserve the parent mutation operation when the merge entry point lives on Mutation (graphql-tools#4549).

    Previously createMergedTypeResolver always used operation: 'query'. When type merging ran during a mutation and the merge entry point existed only under Mutation (or the subgraph rejected mutation fields executed as queries), merged fields came back null.

    Example: two subschemas each expose Mutation.zeroUser / Mutation.oneUser as merge entry points for User. A client mutation that selects fields from both users now re-delegates those merges as mutations, so subgraphs that distinguish mutation vs query resolvers keep working.

    Query-only merge fields (Federation _entities) still delegate as query even when the gateway operation is a mutation. Subscriptions are also unchanged: merges while resolving a subscription event use query, because you cannot re-subscribe for entity fields. Scope follows the mutation-vs-query discussion.

  • Fix type merging for unions queried with inline fragments (graphql-tools#4965 / #4966).

    Typical setup: one subschema returns a stub member (StubMajor { id }) while another resolves the real union members via @merge:

    # students
    union Major = StubMajor
    type StubMajor { id: String! }
    
    # majors
    type Query {
      major(id: String!): Major @merge(keyField: "id")
    }
    union Major = MajorSuccess | MajorError

    Client query:

    major {
      ... on MajorSuccess { id name }
      ... on MajorError { id code }
    }

    Three problems stacked:

    1. @merge on a union only registered concrete members (MajorSuccess / MajorError), not Major itself, so a StubMajor result never triggered merge.

    2. MergedTypeInfo was not built for union types, and planners assumed object/interface getFields().

    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).

    Fixes:

    • Register the abstract union/interface name for @merge as well as concrete members.

    • Build merge info for unions; treat unions as field-less so the abstract planner re-fetches via inline fragments.

    • Flatten nested selection arrays after union field expansion so stub keys are actually requested.

    This goes beyond the schema-extension workaround discussed on the issue.

A whole project to check? Paste its package.json in the dependency check: every deprecated, outdated or vulnerable dependency, with what to upgrade to. Free, no account.