watchQuery with pollInterval ignores no-cache fetchPolicy
See original GitHub issueCurrently, when executing a watchQuery
with a pollInterval
and the fetchPolicy: 'no-cache'
option, the caching option is overridden internally within Apollo to network-only
, causing data to be written to the cache despite the no-cache
fetch policy.
Intended outcome:
client.watchQuery({
query,
pollInterval: 1000,
fetchPolicy: 'no-cache', // No objects should be written to the cache
}).valueChanges.subscribe(...);
Actual outcome:
The cache .write()
method is called with the results of the query
How to reproduce the issue: See ‘Intended outcome’ section
Versions
System:
OS: macOS Mojave 10.14.6
Binaries:
Node: 12.14.0 - /usr/local/bin/node
Yarn: 1.22.4 - /usr/local/bin/yarn
npm: 6.13.4 - /usr/local/bin/npm
Browsers:
Chrome: 81.0.4044.113
Firefox: 61.0.2
Safari: 13.1
npmPackages:
@apollo/client: 3.0.0-beta.44 => 3.0.0-beta.44
Issue Analytics
- State:
- Created 3 years ago
- Reactions:1
- Comments:9 (3 by maintainers)
Top Results From Across the Web
Queries - Apollo GraphQL Docs
To enable polling for a query, pass a pollInterval configuration option to the useQuery ... This cache-first policy is Apollo Client's default fetch...
Read more >ApolloClient - Client (React) - Apollo GraphQL Docs
Specifies the FetchPolicy to be used for this query. Mutations only support a 'no-cache' fetchPolicy. If you don't want to disable the cache,...
Read more >Vue/Apollo/Graphql Client Cannot Read 'Watchquery' Error
GraphQL errors returned by the server after the first request are ignored when using pollInterval.To Reproduce Steps to reproduce the behavior: 1.Write a....
Read more >apollo-cache-inmemory - Awesome JS
Make queries with a pollInterval respect the no-cache fetch policy, ... Remove Ignoring errors sections in link and error handling docs. by @alessbell...
Read more >fetchPolicy option: "no-cache" does not work in useQuery
When you use the useQuery hook, the query you provide is fetched when the component mounts. Whether it's fetched from the server or...
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
Commenting to say this should be resolved in https://github.com/apollographql/apollo-client/pull/10020! Please let us know if this issue is still cropping up after our next release.
All the best, Emmanuel, Intern 😃
This issue might be related to what was reported in #9691