Reputation: 156
I have a component that renders two child components. The child components uses apollo's useQuery
to issue a request to the server. The issue is because apollo-link-dedup
is included when using apollo-client
, only one request is being sent to the server.
I've tried setting the context to forceFetch: true
as specified here but this doesn't seem to work with hooks.
Here's the query:
// Generated query from @graphql-codegen/cli
import { useGetUploadUrlsQuery } from 'types/graphql'
useGetUploadUrlsQuery({
fetchPolicy: 'network-only',
context: {
forceFetch: true,
},
})
Note: Passing in a unique variable bypasses the dedup. Any less hacky solution/workaround that anyone can come up with will be helpful.
Thanks!
Upvotes: 1
Views: 620
Reputation: 84867
This may be a documentation issue. I think the correct key to pass to context
is deduplication
with a value of false
:
useGetUploadUrlsQuery({
fetchPolicy: 'network-only',
context: {
queryDeduplication: false,
},
})
This is noted here. It's not really true that apollo-link-dedup
is "included by default" as indicated in the README -- the logic might be, but the link itself is not.
Upvotes: 1