Ad

How To Manually Fire Multiple Queries In Apollo-client?

- 1 answer

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.

Ad

Answer

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
}
Ad
source: stackoverflow.com
Ad