question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

watchQuery with pollInterval ignores no-cache fetchPolicy

See original GitHub issue

Currently, 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:closed
  • Created 3 years ago
  • Reactions:1
  • Comments:9 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
MrDoomBringercommented, Sep 2, 2022

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 😃

0reactions
jpvajdacommented, Aug 15, 2022

This issue might be related to what was reported in #9691

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found