You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
add graphql "harness" abstraction along with async parse/validate support (graphql#4562)
This PR extends the functionality of the graphql function by allowing users to pass in a custom harness with user-supplied parse/validate/execute/subscribe functions. This allows users to pass custom versions of those functions, enabling a simple API for adding pre/post hooks, a very simplified version of the pattern introduced by [Envelop](https://the-guild.dev/graphql/envelop).
Although this extends what is possible with the graphql function, which is neat, the underlying purpose is not to compete with Envelop and other frameworks, but rather to facilitate them, background at graphql#3421.
The introduction of the `GraphQLParseFn`, `GraphQLValidateFn`, `GraphQLExecuteFn` and `GraphQLSubscribeFn` types for the functions which make up the harness include purposeful maybe-async return types, even though our internal
`parse` and `validate` functions are always sync, to encourage servers and other tooling to expect that user-supplied versions of these functions may have async pre/post hooks.
This is a softened response to the request by Envelop maintainers in graphql#3421 to wrap the `parse` result in a promise. This PR nudges servers and other tooling in that direction by exposing types that return maybe-async results, but is a non-breaking change.
Co-authored-by: Laurin Quast <laurinquast@googlemail.com>
0 commit comments