graphql-js
feat: pass abortSignal to resolvers via GraphQLResolveInfo
#4425
Merged

feat: pass abortSignal to resolvers via GraphQLResolveInfo #4425

glasser
glasser18 days ago👍 2

In #4261 (not yet released in v17) we made abortSignal available to
resolvers via a fifth argument to the field resolver. Among other
things, this means that any code that processes schemas to wrap
resolvers in other functions would have to be aware of this one new
feature and specially thread through the new behavior. It also changed
the TypeScript signature of GraphQLFieldResolver to require passing
the fifth argument (even if undefined).

But the field resolver interface already has a place for GraphQL-JS to
put a grab-bag of helpful named objects for use by resolvers:
GraphQLResolveInfo.

This PR (which is not backwards compatible with v17.0.0-alpha.8, but is
backwards-compatible with v16) moves the abortSignal into
GraphQLResolveInfo.

It also improves the test of this feature to actually make use of the
AbortSignal API (the previous test actually passes when this change
is made, without changing the test to find the AbortSignal in the new
location).

glasser test: actually test use of AbortSignal in resolver
f39fefbf
glasser feat: pass abortSignal to resolvers via GraphQLResolveInfo
6d97f256
glasser glasser requested a review 18 days ago
yaacovCR
yaacovCR commented on 2025-06-04
Conversation is marked as resolved
Show resolved
src/execution/__tests__/executor-test.ts
213213 executeSync({ schema, document, rootValue, variableValues });
214214
215215 expect(resolvedInfo).to.have.all.keys(
216
'abortSignal',
yaacovCR18 days ago

nit: can we put this on the end of the list to match the interface order

glasser18 days ago
yaacovCR
yaacovCR approved these changes on 2025-06-04
glasser Make ordering in test more consistent
aaf0b13e
glasser
glasser18 days ago (edited 18 days ago)

Self-centeredly, I'd love to see an alpha.9 get released after this is merged, as this is, I believe, the only change needed to make the current version of Apollo Server (which is tested against v16 and v17.0.0-alpha.2) also compile against the more recent v17.

benjie
benjie approved these changes on 2025-06-05
yaacovCR yaacovCR merged fba352d4 into next 12 days ago
yaacovCR yaacovCR added PR: feature 🚀
yaacovCR yaacovCR added PR: breaking change 💥
yaacovCR yaacovCR removed PR: feature 🚀

Login to write a write a comment.

Login via GitHub

Reviewers
Assignees
No one assigned
Labels
Milestone