-
Notifications
You must be signed in to change notification settings - Fork 786
useQuery ignores fetchPolicy='no-cache' or 'network-only' for @client query #3315
Comments
Same as #3302 (comment) ? |
It looks similar, but it is actually not, I'm not trying to run two concurrent ('in flight' as linked docs) queries. |
@jBugman any chance you can provide a small runnable reproduction that demonstrates this? Also, I'm curious to know if using |
@hwillson I sketched quick example https://codesandbox.io/s/usequery-client-no-cache-vpw6d |
It happens to me too. "@apollo/react-hooks": "3.1.3", |
Has anyone found a solution to this? |
@jBugman were you able to fix the issue? Can you share your solution? |
No, we actually stopped using Apollo altogether due to this and some other issues. |
@noumanniazi @jBugman @bugzpodder We were able to disable caching by modifying the way we initialized the dataSources. Previously our dataSources look like this:
And then we changed dataSources from an object to a function:
Then we changed the ApolloServer from:
And changed it to:
That did the trick for us. Hope that works for you! This was the source of the discovery: apollographql/apollo-server#1562 |
@vandercloak thanks for the response, actually we end up solving this issue by passing I will try your way as well. This seems like better solution. |
I have this issue as well :/ It's a huge blocker and I'm surprised there's so little discussion about it. |
@AdamZaczek Yeah not a fun issue. Did the solution I mention above not work for you? Curious if it is not a catch all solution. |
@vandercloak Actually, I made a silly mistake and a simple 'network-only' works for us! Your solution looks like a universal one, it should always work due to returning new instances each time. |
using refetch with random variable |
Same problem with |
Below is something similar to what I have working. // hook setup
const [
getAssets,
{ data, refetch },
] = useLazyQuery(GET_ASSETS, { fetchPolicy: 'cache-and-network' }); // original GET request
getAssets({
variables: {
assets: slug,
},
}); // on button click or change of value
refetch({
assets: slug,
}) |
Intended outcome:
@client
query withfetchPolicy
no-cache
ornetwork-only
should always hit local resolver.Actual outcome:
Resolver is only called once, all subsequent requests are cached.
How to reproduce the issue:
Version
@apollo/react-hooks beta 10, 12
apollo-cache-inmemory: ^1.6.2 => 1.6.2
apollo-client: ^2.6.3 => 2.6.3
apollo-link-error: ^1.1.11 => 1.1.11
apollo-link-http: ^1.5.15 => 1.5.15
apollo-link-ws: ^1.0.18 => 1.0.18
The text was updated successfully, but these errors were encountered: