Skip to content

Conversation

MedHeikelBouzayene
Copy link

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.

client: &reqwest::blocking::Client,
url: U,
variables: Vec<Q::Variables>,
) -> Result<crate::Response<Q::ResponseData>, reqwest::Error> {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't this be Result<Vec<crate::Response<...>>, _>?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it will be serde_json::Array

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@MedHeikelBouzayene
Copy link
Author

@tomhoule could you please launch the tests again

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants