feat(core): Support GraphQLRequest.extensions and update subscriptionExchange #3054
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
This updates the
GraphQLRequest
type to contain anextensions
field. This field will currently remain unavailable to bindings/UI code, but can be used to interact with spec extensions in exchanges.Specifically, this enables us to replace
persistedFetchExchange
with apersitedExchange
in the future that only interacts with the rest of the exchange pipeline by modifyingOperation.extensions
without triggering afetch
request.The
subscriptionExchange
has been updated accordingly to receive the entireFetchBody
type, to bring it inline with the defaultfetchExchange
and@urql/core/internal
utilities.This is a breaking change as the properties
key
andcontext
are now missing in the first argument thatforwardSubscription
receives. To compensate, the exchange now passes the entireOperation
as a second argument toforwardSubscription
. Generally this shouldn't affect integrations with libraries likegraphql-ws
.Set of changes
subscriptionExchange
'sforwardSubscription
input withFetchBody
and addOperation
as a second argumentGraphQLRequest.extensions
and expose it oncreateRequest