blomster
blomster

Reputation: 806

ApolloClient - run multiple async requests with different input/variables - something like React-Query's useQueries

Apologies if I've just managed to miss it in the docs, but I can't find a way to do this in Apollo Client.

I've read about query batching, but this in fact the opposite of what I want to do. I want my queries sent as separate isolated queries.

Happy to expand on details if needed, but I think the title says it all.

Upvotes: 2

Views: 305

Answers (1)

blomster
blomster

Reputation: 806

so, my solution has been to create a new component that

  1. returns null (i.e. renders nothing)
  2. runs a useQuery and puts the result into an array (who's setter is passed in from the parent)

This new component sits inside a loop that iterates all my different variable sets that I want to fire the query with.

Upvotes: 1

Related Questions