@graphql-tools/stitching-directives
4.1.7 · 20 Nov 2026MIT251.1k / weekRepositorynpmAtom feed
4.1.7 is the newest release of 4.x.
In short
1 new1 fixed1 internal
Release note
The section about @graphql-tools/stitching-directives of a note shared by several packages.
@graphql-tools/stitching-directives@4.1.2
Patch Changes
Allow
@mergewithoutkeyArgwhen 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
@mergeon zero-arg fields (args.length !== 1). It now allows zero or one argument and only errors when there are multiple args withoutkeyArg/argsExpr.Separately, keyless merges such as:
merge: { Stats: { fieldName: 'stats', args: () => ({}), }, }had no key
selectionSet. When the subschema that ownedQuery.statsdid not have the requested fields (for example querying onlytotalChirpswhile that field lived on the other subschema),finalizeGatewayRequeststripped 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__typenameintofieldNodesByTypeso 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.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 | MajorErrorClient query:
major { ... on MajorSuccess { id name } ... on MajorError { id code } }Three problems stacked:
@mergeon a union only registered concrete members (MajorSuccess/MajorError), notMajoritself, so aStubMajorresult never triggered merge.MergedTypeInfowas not built for union types, and planners assumed object/interfacegetFields().Expanding a bare merge-key field (
id) on a union into... on StubMajor { id }returned an array from the FIELD visitor; graphql-jsvisitnests 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
@mergeas 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.