Intended outcome:
Graphql queries executed within Apollo's tick cycle are grouped into a single request.
Actual outcome:
Apollo sends a request per query, unless using apollo-link-batch-http
which sends an array of requests (which requires server support for parsing these requests).
How to reproduce the issue:
I was trying to get shouldBatch
working as described here (since my back end does not support batched requests via arrays). But this doesn't seem to work any longer. I also can't find any documentation on the flag.
It looks like the current supported approach is to use apollo-link-batch-http
. But that seems to require your BE to support batch requests and doesn't do the transformations described in the linked article.
Version
shouldBatch
is from version 0.3.17 of apollo-client. Keep reading about the batched-http-link and forget about shouldBatch
when using 2.x. If you are on 1.9.x then checkout BatchingNetworkInterfaceOptions
.
As mentioned in https://github.com/apollographql/apollo-client/issues/3275#issuecomment-396092036, using apollo-link-batch-http
is now the recommended way of handling batching with Apollo Client. Yes, it requires that your GraphQL endpoint supports batching in some way. For more details, see the Query batching section of the docs. Thanks!
@hwillson May I suggest that you should really try to remove this post from the apollo blog? It's really leading people down a rabbit hole. I came here myself trying to find out what happened to shouldBatch
because that blog post led me astray.
Thanks @mcmar - I'll pass that along to the docs team. Side note - we just published a new post about query batching, that is up to date: https://blog.apollographql.com/batching-client-graphql-queries-a685f5bcd41b
Most helpful comment
@hwillson May I suggest that you should really try to remove this post from the apollo blog? It's really leading people down a rabbit hole. I came here myself trying to find out what happened to
shouldBatch
because that blog post led me astray.