@graphql-tools/delegate
12.3.4 · 12 Nov 2026MIT15.8M / weekRepositorynpmAtom feed
10.2.23 is the newest release of 10.x.
In short
30 breaking1 deprecated15 new67 fixed7 changed103 internal
- Breaking
Drop Node 14 support. Require Node.js
>= 16 - Breaking
- Breaking
BREAKING CHANGE
- Breaking
ExecutionParams type replaced by Request type
- Breaking
Validations are skipped by default, use validateRequest: true to reenable
- Breaking
delegate: Export executor typings not to have breaking change
- Breaking
Resolver validation options should now be set to
error,warnorignorerather thantrueorfalse. In previous versions, some of the validators caused errors to be thrown, while some issued warnings. This changes brings consistency to validator behavior. - Breaking
The
allowResolversNotInSchemahas been renamed torequireResolversToMatchSchema, to harmonize the naming convention of all the validators. The default setting ofrequireResolversToMatchSchemaiserror, matching the previous behavior.
Release note
The section about @graphql-tools/delegate of a note shared by several packages.
Patch Changes
#6134
a83da08
Thanks @User! - Ignore unmerged fieldsLet's say you have a gateway schema like in the bottom, and
idis added to the query, only if
theageis requested;# This will be sent as-is { user { name } }But the following will be transformed;
{ user { name age } }Into
{ user { id name age } } ```graphql type Query { } type User { id: ID! # is the key for all services name: String! age: Int! # This comes from another service }#6150
fc9c71fThanks @ardatan! - If there are some fields depending on a nested type resolution, wait until it gets resolved then resolve the rest.See packages/federation/test/fixtures/complex-entity-call example for more details. You can see
ProductListneeds some fields fromProductto resolvefirst
Patch Changes
#6126
680351eThanks @ardatan! - When there is a Node subschema, and others to resolve the rest of the entities by using a union resolver as in Federation like below, it was failing. This version fixes that issue.query { node(id: "1") { id # Fetches from Node ... on User { name # Fetches from User } } }type Query { node(id: ID!): Node } interface Node { id: ID! } type User implements Node { id: ID! } type Post implements Node { id: ID! }# User subschema scalar _Any type Query { _entities(representations: [_Any!]!): [_Entity]! } union _Entity = User interface Node { id: ID! } type User implements Node { id: ID! name: String! }# Post subschema scalar _Any union _Entity = Post type Query { _entities(representations: [_Any!]!): [_Entity]! } interface Node { id: ID! } type Post implements Node { id: ID! title: String! }
Patch Changes
Patch Changes
Patch Changes
af7be09Thanks @ardatan! - Hotfix: do not use nullable and nonNullable prefixes if field names don't match
Patch Changes
#6091
9bca9e0Thanks @User, @User! - If the gateway receives a query with an overlapping fields for the subschema, it uses aliases to resolve it correctly.Let's say subschema A has the following schema;
type Query { } interface User { id: ID! name: String! } type Admin implements User { id: ID! name: String! role: String! } type Customer implements User { id: ID! name: String email: String }And let's say the gateway has the following schema instead;
type Query { } interface User { id: ID! name: String! } type Admin implements User { id: ID! name: String! role: String! } type Customer implements User { id: ID! name: String! email: String! }In this case, the following query is fine for the gateway but for the subschema, it's not;
query { user { ... on Admin { id name # This is nullable in the subschema role } ... on Customer { id name # This is non-nullable in the subschema email } } }So the subgraph will throw based on this rule OverlappingFieldsCanBeMerged
To avoid this, the gateway will use aliases to resolve the query correctly. The query will be transformed to the following;
query { user { ... on Admin { id name # This is nullable in the subschema role } ... on Customer { id name: _nullable_name # This is non-nullable in the subschema email } } }#6092
243c353Thanks @ardatan! - If one of the subgraphs are already able to resolve a nested field as inparent-entity-callexample'sCategory.detailsfrom C'sProduct, resolve it from there instead of using type merging.query { product { category { details { # This is coming from C's Product, so resolve it from there instead of Type Merging id name } } } }
Patch Changes
#5913
83c0af0Thanks @enisdenjo! - dependencies updates:Updated dependency
@graphql-tools/schema@^10.0.2↗︎ (from^10.0.0, independencies)Updated dependency
@graphql-tools/utils@^10.0.13↗︎ (from^10.0.5, independencies)
#5913
83c0af0Thanks @enisdenjo! - No unnecessary inline fragment spreads for union types
Patch Changes
Patch Changes
#5477
cfd47827Thanks @ardatan! - dependencies updates:Removed dependency
value-or-promise@^1.0.12↗︎ (fromdependencies)
a59fb765Thanks @ardatan! - Optimizations to get better performance in query planning
Patch Changes
Major Changes
Patch Changes
Patch Changes
Patch Changes
Patch Changes
#5131
f26392a6Thanks @neumark! - Create symbols with Symbol.for() because multiple copies of delegate cause stitching bugs otherwise.
Patch Changes
#5067
492220cbThanks @n1ru4l! - dependencies updates:Updated dependency
@graphql-tools/batch-execute@^8.5.18↗︎ (from8.5.18, independencies)Updated dependency
@graphql-tools/executor@^0.0.14↗︎ (from0.0.14, independencies)Updated dependency
@graphql-tools/schema@^9.0.16↗︎ (from9.0.16, independencies)Updated dependency
@graphql-tools/utils@^9.2.1↗︎ (from9.2.1, independencies)Updated dependency
dataloader@^2.2.2↗︎ (from2.2.2, independencies)Updated dependency
tslib@^2.5.0↗︎ (from~2.5.0, independencies)Updated dependency
value-or-promise@^1.0.12↗︎ (from1.0.12, independencies)
Patch Changes
#5055
30bd4d0cThanks @renovate! - dependencies updates:Updated dependency
dataloader@2.2.2↗︎ (from2.2.1, independencies)
Patch Changes
#5025
b09ea282Thanks @renovate! - dependencies updates:Updated dependency
dataloader@2.2.1↗︎ (from2.1.0, independencies)
Patch Changes
#4995
772b948aThanks @renovate! - dependencies updates:Updated dependency
tslib@~2.5.0↗︎ (from~2.4.0, independencies)
Patch Changes
#4943
a4d36fccThanks @renovate! - dependencies updates:Updated dependency
value-or-promise@1.0.12↗︎ (from1.0.11, independencies)
Patch Changes
Patch Changes
#4890
eb6cd8b6Thanks @ardatan! - Transform provided argument values properly#4890
eb6cd8b6Thanks @ardatan! - Handle argument definitions correctly during delegation and transformations
Patch Changes
Patch Changes
13c24883Thanks @ardatan! - Fix handling argument values in gateway requestb5e6459fThanks @ardatan! - Show warning only if DEBUG env var is present
Patch Changes
Patch Changes
#4778
df5848b8Thanks @saihaj! - dependencies updates:Added dependency
@graphql-tools/executor@0.0.0↗︎ (todependencies)
Patch Changes
Patch Changes
00c4a1a4Thanks @ardatan! - If type is a list but the provided value isn't, do not fail and resolve that value as the member of that list type
Patch Changes
Patch Changes
Major Changes
- Breaking
#4566
d8dc67aaThanks @ardatan! - ## Breaking changesSchema generation optimization by removing
transfomedSchemaparameterPreviously we were applying the transforms multiple times. We needed to introduced some breaking changes to improve the initial wrapped/stitched schema generation performance;
Transform.transformSchemano longer acceptstransformedSchemawhich can easily be created withapplySchemaTransforms(schema, subschemaConfig)instead.Proxying resolver factory function that is passed as
createProxyingResolvertoSubschemaConfigno longer takestransformedSchemawhich can easily be created withapplySchemaTransforms(schema, subschemaConfig)instead.
stitchSchemasdoesn't take nested arrays of subschemasstitchSchemasno longer accepts an array of arrays of subschema configuration objects. Instead, it accepts an array of subschema configuration objects or schema objects directly.stitchSchemasno longer prunes the schema withpruningOptionsYou can use
pruneSchemafrom@graphql-tools/utilsto prune the schema instead.stitchSchemasno longer respect "@computed" directive if stitchingDirectivesTransformer isn't appliedAlso
@graphql-tools/stitchno longer exportscomputedDirectiveTransformeranddefaultSubschemaConfigTransforms. Instead, use@graphql-tools/stitching-directivespackage for@computeddirective. Learn more about setting it upcomputedFieldshas been removed from the merged type configurationMergeTypeConfig.computedFieldssetting has been removed in favor of new computed field configuration written as:merge: { MyType: { fields: { myComputedField: { selectionSet: '{ weight }', computed: true, } } } }A field-level
selectionSetspecifies field dependencies while thecomputedsetting structures the field in a way that assures it is always selected with this data provided. TheselectionSetis intentionally generic to support possible future uses. This new pattern organizes all field-level configuration (includingcanonical) into a single structure.
Patch Changes
#4624
e3167edcThanks @n1ru4l! - Fix CommonJS TypeScript resolution withmoduleResolutionnode16ornodenext
Minor Changes
Support TypeScript module resolution.
Patch Changes
Remove graphql-executor to have smaller bundle size
Patch Changes
Use caret range for the tslib dependency
Patch Changes
Relax subschema error path check
...as (apparently) some implementations may return path as
nullrather than not returning a path.
Patch Changes
Refine generic typings using
extends Xwhen appropriateTypescript 4.7 has stricter requirements around generics which is explained well in the related PR: #48366
These changes resolve the errors that these packages will face when attempting to upgrade to TS 4.7 (still in beta at the time of writing this). Landing these changes now will allow other TS libraries which depend on these packages to experiment with TS 4.7 in the meantime.
Patch Changes
Bump data-loader and cross-undici-fetch
Minor Changes
enhance(delegate): use graphql-executor for subscriptions
Minor Changes
Forward gateway operation's name to subschema executors
Patch Changes
Fix - align versions
Patch Changes
enhance(delegate): type is now inferred from the transformed subschema instead of unified schema
enhance(stitch): support promises in key functions
Patch Changes
delegate: Do not resolve the type twice
Patch Changes
visitResult: Ignore if field not present in visited object
Minor Changes
Add better type support for stitchSchemas using subschema transformations
Patch Changes
enhance: Avoid using globalThis
Patch Changes
isAsyncIterable should check if it is an object with iterator factory function
Patch Changes
enhance: Use ^ for tslib dependency
Minor Changes
enhance: Make operationType optional
Minor Changes
Getting ready for GraphQL v16
Patch Changes
enhance: Show more clear error messages for aggregated error
Patch Changes
batch-execute enhancements:
fixes bugs with batched fragment definitions
unpathed errors are now returned for all batch results
the "graphqlTools" prefix is simplified down to just "_"
new tests and documentation
Patch Changes
delegate: Pass an empty array if fieldNodes is falsy
Minor Changes
enhance(utils): copy inspect util from graphql-js
GraphQL v16 support
enhance(utils): move memoize functions to utils
enhance(utils): copy collectFields from graphql-js@16 for backwards compat
Patch Changes
enhance: Remove TypeMap and small improvements
Patch Changes
Use version ranges instead of a fixed version for the graphql-tools package versions
Patch Changes
Fix nested type merges with repeated children ignore all but first occurrence
Patch Changes
delegate: Visit list values to collect variables
Patch Changes
delegate: Collect variables from directives on FragmentSpread
Patch Changes
delegate: Handle variables correctly
Patch Changes
delegate: Ignore if stitchingInfo is not in extensions
Patch Changes
delegate: Fix ESM import
Major Changes
- Breaking
BREAKING CHANGE
Remove
rootValuefrom subschemaConfigPass it through
ExecutionParamsor delegation optionsDo not pass
info.rootValueifrootValueis falsy
- Breaking
BREAKING CHANGES;
Refactor the core delegation transforms into individual functions to modify request and results. This will improve the performance considerably by reducing the number of visits over the request document.
Replace
CheckResultAndHandleErrorswithcheckResultAndHandleErrorsRemove
delegationBindingsReplace
AddArgumentsAsVariables,AddSelectionSets,AddTypenameToAbstract,ExpandAbstractTypes,FilterToSchema,VisitSelectionSetsandWrapConcreteTypeswithprepareGatewayDocumentandfinalizeGatewayRequest
- Breaking
ExecutionParams type replaced by Request type
rootValue property is now a part of the Request type.
When delegating with delegateToSchema, rootValue can be set multiple ways:
when using a custom executor, the custom executor can utilize a rootValue in whichever custom way it specifies.
when using the default executor (execute/subscribe from graphql-js): -- rootValue can be passed to delegateToSchema via a named option -- rootValue can be included within a subschemaConfig -- otherwise, rootValue is inferred from the originating schema
When using wrapSchema/stitchSchemas, a subschemaConfig can specify the createProxyingResolver function which can pass whatever rootValue it wants to delegateToSchema as above.
- Breaking
BREAKING CHANGES;
Rename
RequesttoExecutionRequestAdd required
operationType: OperationTypeNodefield inExecutionRequestAdd
contextincreateRequestandcreateRequestInfoinstead ofdelegateToSchema
It doesn't rely on info.operation.operationType to allow the user to call an operation from different root type. And it doesn't call getOperationAST again and again to get operation type from the document/operation because we have it in Request and ExecutionParams #3166
Improvements;
Memoize
defaultExecutorfor a singleGraphQLSchemaso allowgetBatchingExecutorto memoizebatchingExecutorcorrectly.And there is no different
defaultExecutoris created forsubscriptionand other operation types. Only one executor is used.
Batch executor is memoized by
executorreference butcreateDefaultExecutordidn't memoize the default executor so this memoization wasn't working correctly onbatch-executeside. github.com/ardatan/graphql-tools/blob/remove-in… - Breaking
BREAKING CHANGE
Now it uses the native
AggregateErrorimplementation. The major difference is the individual errors are kept undererrorsproperty instead of the object itself withSymbol.iterator.
// From; for (const error of aggregateError) // To; for (const error of aggregateError.errors)
- Breaking
Validations are skipped by default, use validateRequest: true to reenable
- Breaking
BREAKING CHANGE
Remove Subscriber and use only Executor
Now
Executorcan receiveAsyncIterableand subscriptions will also be handled byExecutor. This is a future-proof change for defer, stream and live queries
Patch Changes
Use value-or-promise to streamline working with sync values or async promises
Patch Changes
delegate: Handle executor errors
Patch Changes
Allows
MergedTypeConfigto be written with anentryPointsarray for multiple merged type entry points, each with their ownfieldNameandselectionSet:{ schema: testSchema, merge: { Product: { entryPoints: [{ selectionSet: '{ id }', fieldName: 'productById', key: ({ id, price, weight }) => ({ id, price, weight }), argsFromKeys: (key) => ({ key }), }, { selectionSet: '{ upc }', fieldName: 'productByUpc', key: ({ upc, price, weight }) => ({ upc, price, weight }), argsFromKeys: (key) => ({ key }), }], } } }These multiple entry points accommodate types with multiple keys across services that rely on a central service to join them, for example:
Catalog service:
type Product { upc }Vendors service:
type Product { upc id }Reviews service:
type Product { id }
Given this graph, the possible traversals require the Vendors service to provide entry points for each unique key format:
Catalog > Vendors > ReviewsCatalog < Vendors > ReviewsCatalog < Vendors < Reviews
Is it highly recommended that you enable query batching for subschemas with multiple entry points.
Patch Changes
- Breaking
delegate: Export executor typings not to have breaking change
Minor Changes
types: Add TContext to stitchSchemas and executor
Patch Changes
- Deprecated
Deprecates the
MergeTypeConfig.computedFieldssetting (with backwards-compatible warning) in favor of new computed field configuration written as:merge: { MyType: { fields: { myComputedField: { selectionSet: '{ weight }', computed: true, } } } }A field-level
selectionSetspecifies field dependencies while thecomputedsetting structures the field in a way that assures it is always selected with this data provided. TheselectionSetis intentionally generic to support possible future uses. This new pattern organizes all field-level configuration (includingcanonical) into a single structure.
Patch Changes
fix(delegate) fix array check
enhance(stitch) canonical merged type and field definitions. Use the @canonical directive to promote preferred type and field descriptions into the combined gateway schema.
Patch Changes
stitch: Type merging for nested root types
Because root types do not usually require selectionSets, a nested root type proxied to a remote service may end up having an empty selectionSet, if the nested root types only includes fields from a different subservice.
Empty selection sets return null, but, in this case, it should return an empty object. We can force this behavior by including the __typename field which exists on every schema.
Addresses #2347.
In the future, we may want to include short-circuiting behavior that when delegating to composite fields, if an empty selection set is included, an empty object is returned rather than null. This short-circuiting behavior would be complex for lists, as it would be unclear the length of the list...
delegate: Resolve external values only once
Because items in a list may be identical and the defaultMergedResolver mutates those objects when resolving them as external values, a check is required so that the mutation happens only once.
Partially addresses #2304
Patch Changes
typeMerging: Enable subschemas to use keys that have been renamed via transforms
batch-delegate: Proxy batched errors
Patch Changes
delegate: Add selectionSets prior to expanding abstract types
Patch Changes
enhance(stitch): custom merge resolvers
Patch Changes
delegate: Import AggregateError polyfill
Patch Changes
delegate: WrapConcreteTypes should not process fragments that are not on a root type (#2173)
Patch Changes
stitch: Fix mergeExternalObject regressions
v7 introduced a regression in the merging of ExternalObjects that causes type merging to fail when undergoing multiple rounds of merging.
Patch Changes
delegate: Fix type error with
argumentsbeing undefined
Major Changes
- Breaking
Breaking Changes:
Schema Generation and Decoration API (@graphql-tools/schema)
- Breaking
Resolver validation options should now be set to
error,warnorignorerather thantrueorfalse. In previous versions, some of the validators caused errors to be thrown, while some issued warnings. This changes brings consistency to validator behavior. - Breaking
The
allowResolversNotInSchemahas been renamed torequireResolversToMatchSchema, to harmonize the naming convention of all the validators. The default setting ofrequireResolversToMatchSchemaiserror, matching the previous behavior.
Schema Delegation (delegateToSchema & @graphql-tools/delegate)
- Breaking
The
delegateToSchemareturn value has matured and been formalized as anExternalObject, in which all errors are integrated into the GraphQL response, preserving their initial path. Those advanced users accessing the result directly will note the change in error handling. This also allows for the deprecation of unnecessary helper functions includingslicedError,getErrors,getErrorsByPathSegmentfunctions. Only external errors with missing or invalid paths must still be preserved by annotating the remote object with special properties. The newgetUnpathedErrorsfunction is therefore necessary for retrieving only these errors. Note also the newannotateExternalObjectandmergeExternalObjectsfunctions, as well as the renaming ofhandleResulttoresolveExternalValue. - Breaking
Transform types and the
applySchemaTransformsare now relocated to thedelegatepackage;applyRequestTransforms/applyResultTransformsfunctions have been deprecated, however, as this functionality has been replaced since v6 by theTransformerabstraction. - Breaking
The
transformRequest/transformResultmethods are now provided additionaldelegationContextandtransformationContextarguments -- these were introduced in v6, but previously optional. - Breaking
The
transformSchemamethod may wish to create additional delegating resolvers and so it is now provided thesubschemaConfigand final (non-executable)transformedSchemaparameters. As in v6, thetransformSchemais kicked off once to produce the non-executable version, and then, if a wrapping schema is being generated, proxying resolvers are created with access to the (non-executable) initial result. In v7, the individualtransformSchemamethods also get access to the result of the first run, if necessary, they can create additional wrapping schema proxying resolvers. - Breaking
applySchemaTransformsparameters have been updated to match and support thetransformSchemaparameters above.
Remote Schemas & Wrapping (wrapSchema, makeRemoteExecutableSchema, and @graphql-tools/wrap)
- Breaking
wrapSchemaandgenerateProxyingResolversnow only take a single options argument with named properties of typeSubschemaConfig. The previously possible shorthand version with first argument consisting of aGraphQLSchemaand second argument representing the transforms should be reworked as aSubschemaConfigobject. - Breaking
Similarly, the
ICreateProxyingResolverOptionsinterface that provides the options for thecreateProxyingResolverproperty ofSubschemaConfigoptions has been adjusted. Theschemaproperty previously could be set to aGraphQLSchemaor aSubschemaConfigobject. This property has been removed in favor of asubschemaConfigproperty that will always be aSubschemaConfigobject. Thetransformsproperty has been removed; transforms should be included within theSubschemaConfigobject.` - Breaking
The format of the wrapping schema has solidified. All non-root fields are expected to use identical resolvers, either
defaultMergedResolveror a custom equivalent, with root fields doing the hard work of proxying. Support for custom merged resolvers throughtcreateMergedResolverhas been deprecated, as custom merging resolvers conflicts when using stitching's type merging, where resolvers are expected to be identical across subschemas. - Breaking
The
WrapFieldstransform'swrappingResolveroption has been removed, as this complicates multiple wrapping layers, as well as planned functionality to wrap subscription root fields in potentially multiple layers, as the wrapping resolvers may be different in different layers. Modifying resolvers can still be performed by use of an additional transform such asTransformRootFieldsorTransformObjectFields. - Breaking
The
ExtendSchematransform has been removed, as it is conceptually simpler just to usestitchSchemaswith one subschema. - Breaking
The
ReplaceFieldsWithFragment,AddFragmentsByField,AddSelectionSetsByField, andAddMergedTypeSelectionSetstransforms has been removed, as they are superseded by theAddSelectionSetsandVisitSelectionSetstransforms. TheAddSelectionSetspurposely takes parsed SDL rather than strings, to nudge end users to parse these strings at build time (when possible), rather than at runtime. Parsing of selection set strings can be performed using theparseSelectionSetfunction from@graphql-tools/utils.
Schema Stitching (stitchSchemas & @graphql-tools/stitch)
- Breaking
stitchSchemas'smergeTypesoption is now true by default! This causes theonTypeConflictoption to be ignored by default. To useonTypeConflictto select a specific type instead of simply merging, simply setmergeTypesto false. - Breaking
schemasargument has been deprecated, usesubschemas,typeDefs, ortypes, depending on what you are stitching. - Breaking
When using batch delegation in type merging, the
argsFromKeysfunction is now set only via theargsFromKeysproperty. Previously, ifargsFromKeyswas absent, it could be read fromargs. - Breaking
Support for fragment hints has been removed in favor of selection set hints.
- Breaking
stitchSchemasnow processes allGraphQLSchemaandSubschemaConfigsubschema input into newSubschemaobjects, handling schema config directives such aso@computedas well as generating the final transformed schema, stored as thetransformedSchemaproperty, if transforms are used. Signatures of theonTypeConflict,fieldConfigMerger, andinputFieldConfigMergerhave been updated to include metadata related to the original and transformed subschemas. Note the property name change foronTypeConflictfromschematosubschema.
Mocking (addMocksToSchema and @graphql-tools/mock)
- Breaking
Mocks returning objects with fields set as functions are now operating according to upstream graphql-js convention, i.e. these functions take three arguments,
args,context, andinfowithparentavailable asthisrather than as the first argument.
Other Utilities (@graphql-tools/utils)
- Breaking
filterSchema'sfieldFilterwill now filter all fields across Object, Interface, and Input types. For the previous Object-only behavior, switch to theobjectFieldFilteroption. - Breaking
Unused
fieldNodesutility functions have been removed. - Breaking
Unused
typeContainsSelectionSetfunction has been removed, andtypesContainSelectionSethas been moved to thestitchpackage. - Breaking
Unnecessary
Operationtype has been removed in favor ofOperationTypeNodefrom upstream graphql-js. - Breaking
As above,
applySchemaTransforms/applyRequestTransforms/applyResultTransformshave been removed from theutilspackage, as they are implemented elsewhere or no longer necessary.
Related Issues
Proxy all the errors
Fix typings #1614
Disable implicit schema pruning #1817
Mocks not working for functions #1807
Patch Changes
enhance(stitching): improve error message for unknown types
Bump all packages to allow adjustments
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.