Backwards compatible retention of extension parsing for async reqwest
#928
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?
Partially addresses the needs of #927.
What effects does this change have?
Changes the
ReqwestExt
trait to returnDelayedResponse
.Calling
DelayedResponse::retain_extensions::<T>
andawait
ing will deserialise theextensions
field using the shape of T.Directly
await
ingDelayedResponse
(i.e. the previous behaviour, thereby maintaining backwards compatibility) will produce anImmediateResponse
, which will ignore the contents of the "extensions" field.Adds
futures-lite
to make implementing ofstd::future::Future
simpler.If you think the implementation could be improved to avoid needing
futures::FutureExt
, please make any changes you deem necessary.Adds
tokio = { version = "1", features = ["macros"] }
andmockito = "1.4.0"
to dev dependencies to provide an asynchronous mock server for testing purposes.cynic/tests/http.rs
provides a comparison of their usages.Examples:
For a GraphQL server that responds with
Including
extensions
withDelayedResponse::retain_extensions
Will produce a response with
extensions: Some(Extensions { code: 401 } )
.Backwards compatible
Will produce a response with
extensions: Some(IgnoredAny)
.