Reputation: 2859
I have multiple queries that I want to fetch after each 10 seconds, I can fetch the queries like this:
compose(
graphql(QUERY_1, {
options: {
pollInterval: 10000
}
}),
graphql(QUERY_2, {
options: {
pollInterval: 10000
}
}),
....
)
but that would make more than one intervals which I don't want. Is there any way in react-apollo
to make multiple queries under a single interval. For example something like this:
compose(
graphql([QUERY_1, QUERY_2],
options: { pollInterval: 10000 }
),
...
)
Upvotes: 0
Views: 2559
Reputation: 2859
The way I did it for now is combine multiple queries in one e.g.
const QUERIES_GROUP = gql`
{
QUERY_1 ...,
QUERY_2 ...
}
`
compose(
graphql(QUERIES_GROUP, {
options: { pollInterval: 10000 }
})
)
The disadvantage of using above approach is that we cannot reuse query QUERY_1
or QUERY_2
in some other component
Another option is to use batching https://www.apollographql.com/docs/link/links/batch-http.html
Upvotes: 1