SkyPower
SkyPower

Reputation: 123

How to manually fire multiple queries in Apollo-client?

I am trying to manually fire multiple queries, similarly to refetchQueries that is available after a mutation.

this.props.client.query(
      {
        query: getPlacesForDateQuery
      },
      {
        query: getTimesQuery
      }
    )

This works only for the 1st query and it ignores the others. I am wondering if there is a way to do it, other than manually firing each query separately and waiting for it to complete.

Note: I don't know if it matters, but I am not using the new Query component.

Upvotes: 1

Views: 332

Answers (1)

Divide by Zero
Divide by Zero

Reputation: 1474

Check out this helpful article

I think your syntax is slightly off. You can compose multiple queries into one. This is your mistake here. Try it like so:

query ___composed {
  author {
    firstName
    lastName
  }
  fortuneCookie
}

or you can write two queries like so:

query firstQuery {
   author {
    firstName
    lastName
  }
}
query secondQuery {
  fortuneCookie
}

Upvotes: 1

Related Questions