feat: support batch queries#550
feat: support batch queries#550MedHeikelBouzayene wants to merge 5 commits intographql-rust:mainfrom
Conversation
graphql_client/src/reqwest.rs
Outdated
| client: &reqwest::blocking::Client, | ||
| url: U, | ||
| variables: Vec<Q::Variables>, | ||
| ) -> Result<crate::Response<Q::ResponseData>, reqwest::Error> { |
There was a problem hiding this comment.
Shouldn't this be Result<Vec<crate::Response<...>>, _>?
There was a problem hiding this comment.
it will be serde_json::Array
There was a problem hiding this comment.
I think the shape of the ResponseData is from generated code, not a serde_json::Value, so I don't think serde_json::Array would appear anywhere, right?
There was a problem hiding this comment.
Also, this approach only works if it's a batch of the same query — in GraphQL, the queries can be different. It would not be straightforward to statically type, though.
There was a problem hiding this comment.
@tomhoule, If we want different queries, we should serialize the queries and have a serde_json::Value as a result since the trait GraphqlQuery is not object safe. if that's okay with you I can do that.
There was a problem hiding this comment.
There's little utility to that, since this crate is only about the type safety. Let's just document that it's a batch of identical queries.
My only reservation left is that I still don't understand why this doesn't return Result<Vec<crate::Response<Q::ResponseData>>, reqwest::Error> instead of Result<crate::Response<Q::ResponseData>, reqwest::Error>.
There was a problem hiding this comment.
yes it makes more sense to have it as Vec<Q::ResponseData>, I did update it
|
@tomhoule could you please launch the tests again |
Adds support for executing multiple GraphQL operations in a single HTTP request (batch query).
This enables sending an array of query objects with their respective variables, improving performance for use cases that require multiple small requests.
Includes:
Support for serializing and sending batched query payloads.
Adjusted request builder to handle both single and batch query modes.
Unit tests covering multi-query payload serialization and response handling.