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.

Error when using pollInterval with fetchPolicy cache-and-network

See original GitHub issue

When I’m trying to use fetchPolicy cache-and-network with pollInterval I have next error: Uncaught Error: Queries that specify the cache-first and cache-only fetchPolicies cannot also be polling queries. Could be related to this fix: https://github.com/apollographql/apollo-client/pull/3372 Since now we reset fetchPolicy to cache-first internally when using cache-and-network. Would be nice to fix this issue or at least update error message.

Workaround that I use for now:

  ...
  componentDidMount() {
    setTimeout(() => {
      this.props.data.startPolling(1000);
    }, 0)
  }
  ...

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:5
  • Comments:11 (2 by maintainers)

github_iconTop GitHub Comments

11reactions
natterstefancommented, Jun 20, 2019

Hi @danilobuerger,

Closing as no reproduction was provided in one week.

Sorry, but @OHUSAR did provide a Demo: https://github.com/OHUSAR/react-apollo-error-template. And the demo still shows what’s going wrong.

image

We are still having this issue. Can you take a look at the issue again, please?

4reactions
danilobuergercommented, Jan 29, 2019

Closing as no reproduction was provided in one week. Feel free to reopen if you have a minimal reproduction.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Queries - Apollo GraphQL Docs
When your component renders, useQuery returns an object from Apollo Client that contains loading , error , and data properties you can use...
Read more >
useQuery pollInterval with cache-and-network doesn't stop to ...
I've made the issue here in apollo-client repository. It works well with other fetchPolicy options but it doens't work correctly with ...
Read more >
client.watchQuery cannot be called with fetchPolicy set to ...
I get this error on v3.4.17 and v3.4.0 which were mentioned in earlier posts. I think the issue is caused by @apollo/react-hooks.
Read more >
Interfaces: ApolloQuery - Apollo Elements
When someone chooses cache-and-network or network-only as their initial FetchPolicy, they often do not want future cache updates to trigger unconditional ...
Read more >
Graphql Client with React & Apollo | by Héla Ben Khalfallah
pollInterval : 500, // fetchPolicy: 'cache-and-network' }); if (loading) return <p>Loading...</p>; if (error) return <p>Error :(</p>;
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