nextFetchPolicy doesn't work as expected.
See original GitHub issuePreface: My understanding from the docs has been that while using useQuery, the first execution takes place as specified by fetch-policy. All subsequent executions of the query follow nextFetchPolicy(If Specified).
Intended outcome: I set the fetchPolicy to cache-first and nextFetchPolicy to network-only expecting that a network request will be made on every execution after the first.
Actual Outcome: But the same isn’t replicating. On subsequent executions, data is getting read from cache and no network-request is made.
How to reproduce the issue: Here is a codesandbox to check the same Link.
Versions version : 3.4.8
Am I misunderstanding nextFetchPolicy or is this a bug?
Issue Analytics
- State:
- Created 2 years ago
- Comments:6 (3 by maintainers)
Top Results From Across the Web
Setting The Correct Fetch Policy - Help - Apollo Community
I'm close to finishing my product. Throughout the software I use a fetch policy of network-only and a nextFetchPolicy of cache-first based on ......
Read more >React Apollo: Understanding Fetch Policy with useQuery
A cache-only query throws an error if the cache does not contain data for all requested fields. cache-and-network, Apollo Client executes the ...
Read more >Pitfalls I fell into during Apollo Client 3.0 migration
Recently I worked on migrating Apollo Client to 3.0 from 2.6 in our ... On the other hand, we found cache updates do...
Read more >graphql - 3 level type object does not return expected results
i am working with apollo graphql and i have a query with 3 nested type objects. as shown below
Read more >Prevent an Unnecessary Refetch with nextFetchPolicy and ...
I recently figured out the cause of a strange issue due to a change in how the cache-and-network fetch policy works in Apollo...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
fetchPolicy
is used every time the component mounts.nextFetchPolicy
is used for every query execution after the component mounts. When you unmount and remount the component, it resets tofetchPolicy
. Unfortunately it isn’t super clear in the docs exactly what “first execution” means.@santialbo “changing the variables” and “calling refetch” are not the only things that could cause a query execution. I believe if some related data in the cache gets updated, that is another scenario where the query would get re-executed.