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

How to support batched operations like in Apollo? #76

Closed
a613 opened this issue Aug 9, 2018 · 1 comment
Closed

How to support batched operations like in Apollo? #76

a613 opened this issue Aug 9, 2018 · 1 comment

Comments

@a613
Copy link

a613 commented Aug 9, 2018

Apollo server supports batched operations in a single POST request:

[{ query: '{ testString }' }, { query: 'query q2{ test(who: "you" ) }' }]

Our graphql client uses apollo-link-batch-http to send requests like that, with up to 10 operations combined and sent as an array of maps.

Running lacinia-pedestal, individually sent operations work, but when our existing client sends batched operations, lacinia returns an error, saying "Request content type must be application/graphql or application/json" (which isn't even accurate - the request has a content-type of application/json - but it's the default case in com.walmartlabs.lacinia.pedestal/query-not-found-error).

I can't tell if it's the same feature described in graphql/graphql-spec#375.

The lacinia-pedestal docs do not appear to mention support for this, and I think com.walmartlabs.lacinia.pedestal/extra-query only works with a top-level operation map.

What's the best way to support these types of requests using lacinia-pedestal?

I thought about writing new interceptors, but every single one seems really set on adding keys to the context/request maps assuming that there is only one operation.

@a613 a613 changed the title How to support batched operations like in apollo? How to support batched operations like in apollo-link-batch-http? Aug 9, 2018
@a613 a613 changed the title How to support batched operations like in apollo-link-batch-http? How to support batched operations like in Apollo? Aug 9, 2018
@hlship
Copy link
Member

hlship commented Sep 20, 2018

We don't currently have any plans to support batched operations. In your above example, it would be quite reasonable to execute it as a single query document; if your resolvers support it, you'll even see the queries executing in parallel.

It might be possible to hack this using a Pedestal interceptor.

We can discuss this further on the #graphql slack channel.

@hlship hlship closed this as completed Sep 20, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants