0

I have my client app written in React + Apollo and backend in Python + Ariadne. Is there any way to handle batched arrays of queries in Ariadne?

I set custom Link in my client:

const apolloClient = new ApolloClient({
   cache: InMemoryCache(),
   link: new BatchHttpLink({ uri })
});

Client started sending queries in the array as expected, but unfortunately I get 400 Bad Request, because backend was expecting an object instead of the array.

I'm not sure if I should create a middleware for Ariadne and handle requests manually or there is some automatic solution? I was trying to Google, but phrases ariadne + batch/batching does not seem to appear together...

Nickon
  • 9,652
  • 12
  • 64
  • 119

1 Answers1

1

I haven't really worked with this particular GraphQL server implementation but it's worth noting that the "batched link" indeed simply sends an array of queries, which is a spec extension and not part of the original spec, so if your server-implementation and GraphQL endpoint don't support this you'll have to manually add this.

This isn't a particularly special piece of logic though. It executes all the queries from the array as if they were sent separately. You can find a strawman spec document for this behaviour here: https://github.com/graphql/graphql-over-http/blob/main/rfcs/Batching.md

Phil Plückthun
  • 1,381
  • 9
  • 14