Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for query batching #513

Closed
sav007 opened this issue Jun 7, 2017 · 12 comments
Closed

Add support for query batching #513

sav007 opened this issue Jun 7, 2017 · 12 comments

Comments

@sav007
Copy link
Contributor

sav007 commented Jun 7, 2017

Ref docs:
http://dev.apollodata.com/core/network.html#query-batching
https://dev-blog.apollodata.com/query-batching-in-apollo-63acfd859862

@Radivarig
Copy link

Any news on this?

@sav007
Copy link
Contributor Author

sav007 commented Jul 2, 2018

No any updates, not sure what is the priority for this feature. Not all implementations of GraphQL server supports multiple queries execution support. And with client batching (via aliases) seems to me like a workaround.

@sav007 sav007 removed this from the 0.3.3 milestone Jul 2, 2018
@Radivarig
Copy link

I've got a dynamic list of items that needs to be inserted to a table and have thought that mapping each item to a mutation would batch them up and send as an array in a single request. Is there some existing solution I'm missing?

@Radivarig
Copy link

I'm using postgraphile, last week this plugin was released postgraphile-plugin-nested-mutations mentioned in postgraphile#793, it allows nested mutations, I can now create or connect existing foreign key items from a variable array, all in one query :)

@mandrizzle
Copy link

mandrizzle commented Aug 28, 2018

I have a solution to this and believe this is possible using a single OkHttp interceptor. I am unsure of what the requirements are other than:

  1. There should be a custom batch timing interval and max batch size
  2. Join the queries into a single JSON array for the request
  3. Expect a JSON array as a response and dispatch a response to each item in the same order they came in
  4. If # requests do not match # responses fail the entire batch

What I have not yet done but is still possible by adding custom headers to each request:

  1. Batch queries and mutations separately
  2. Don't batch certain requests

If the above is all that is needed, I have a working solution and would be willing to submit a PR. If not, what else needs to be handled?

@DJansse
Copy link

DJansse commented Nov 14, 2018

Any update on this topic / discussion?
We're using Apollo GQL on Web, iOS and Android and are thinking about updating the server to support transport level batching of queries...

Kind regards

@mandrizzle
Copy link

So from my original comment, I have that implementation working great however, it needs to create a new thread for each request which is not ideal. I am working on a refactor that now sets a custom CallFactory to reduce the number of threads required to just one. Just need to test it out and I'll keep y'all updated.

@imankhdrpst
Copy link

hi @mandrizzle , Did you have anything implemented, could you post them here ?

@spawrksvrbo
Copy link

Do we have any updates on this? Wondering if someone needs support to help get this over the line, it's super helpful to be able to query batch and I'm surprised this has been open for so long. Would love to know how to help.

@rocketraman
Copy link

Hasura is another backend that can leverage multiple mutations in a request to ensure all-or-nothing via a db transaction: https://hasura.io/docs/latest/graphql/core/databases/postgres/mutations/multiple-mutations.html.

@joaquim-verges
Copy link
Contributor

Took a stab at an implementation here: #3117 if anyone is interested

@martinbonnin
Copy link
Contributor

Closed with #3117

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

No branches or pull requests

9 participants