feat!: rework extension handling on errors & responses#1130
Open
feat!: rework extension handling on errors & responses#1130
Conversation
✅ Deploy Preview for cynic-querygen-web canceled.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Why are we making this change?
GraphQl allows a server to provide arbitrary extensions on responses & errors within a response. Currently cynic only supports decoding these extensions on errors. It does this with generic parameters on the response & error type.
These generic parameters are a little awkward when using the cynic http code - as we need a way to pass through the expected extension types. This led to the addition of a
retain_extensionsfunction.Some users would also like to access extensions on the response itself.
What effects does this change have?
Adds support for extensions on the response type. Rather than adding this as a new generic parameter we now store extensions in a
serde_json::Valueand provide functionality for deserialising from that. This saves us from adding another generic parameter everywhere, and saves us from having to implement functions likeretain_extensionsin the http layer.Fixes #1016