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.

Errors lost on cached results

See original GitHub issue

I’m using apollo and react to call a query that returns mixed results: error(s) and some data. In order to handle the errors, but still be able to use the information given, I’m using the errorPolicy: "all" option in the query.

<Query query={query} variables={variables as any} errorPolicy='all'>
    {({loading, error, data}) => { ... }}
</Query>

The first time I mount the component data is populated with the partial informations and error with the errors returned by the query. If I change the route (unmounting the component) and then return on it, it shows the cached partial data but no errors, so I’m not able to handle errors anymore and detect that these are partial informations.

Intended outcome: The component shows me the original errors along with the cached data.

Actual outcome: The props error is undefined, the partial data are passed as if the query didn’t return any error.

How to reproduce the issue: Create a query that returns both data and error.

Version

"react-apollo": "2.5.2", "apollo-client": "^2.5.1",

Reference to docs:

Screen Shot 2019-03-27 at 8 43 37 AM

From the docs ^^^^^

https://www.apollographql.com/docs/react/features/error-handling

If this issue looks familiar thats because i stole part of the description from here. An issue that was previously opened and then closed.

Im not sure why that issue was closed as a solution to the original issue was never found.

Note: I am NOT using SSR, i’m simply using the in meme cache.

Issue Analytics

  • State:open
  • Created 4 years ago
  • Reactions:9
  • Comments:23 (6 by maintainers)

github_iconTop GitHub Comments

11reactions
KosGrilliscommented, Mar 24, 2020

Can we expect this to be fixed by the Apollo team? Are there any workarounds for hook-based queries?

7reactions
lifeiscontentcommented, Oct 8, 2020

Ping @hwillson any updates here?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Reading and writing data to the cache - Apollo GraphQL Docs
If the cache is missing data for any of the query's fields, readQuery returns null . It does not attempt to fetch data...
Read more >
Solving Runtime Errors and Other Issues Caused by Your ...
How to Clear Your Browser Cache · Click the "more" icon at the top right. · Select More Tools > Clear browsing data......
Read more >
SQL Server diagnostics added to detect unreported I/O ...
The Lost Write behavior occurs when the page that is read back is still the older version of the data, even after a...
Read more >
Cache data may be lost when replacing the my field of a ...
You may need to return an id for Apollo to uniquely identify that object in the cache. I think this issue is similar...
Read more >
Avoid This Mistake When Caching Asynchronous Results
Learn how to properly cache promise results in JavaScript. ... If the resource is missing from the cache, each request ends up initiating...
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