Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix incorrect documentation on error handling #4237

Closed
wants to merge 1 commit into from

Conversation

tobobo
Copy link

@tobobo tobobo commented Dec 14, 2018

The documentation on errorPolicy was incorrect with respect to the way errors are cached. This updates the docs for parity with Apollo's current functionality.

Fixing this so that future developers do not spend too much time trying to figure out why error cacheing isn't working for them.

The documentation on `errorPolicy` was incorrect with respect to the way errors are cached. This updates the docs for parity with Apollo's current functionality.
@tobobo
Copy link
Author

tobobo commented Dec 14, 2018

The above PRs have some additional information on this missing functionality.

@hwillson
Copy link
Member

hwillson commented Jan 2, 2019

Thanks for submitting this PR @tobobo. The docs are correct however. The errors aren't stored in the data store part of the Apollo Cache, but they are stored in the query store part of the cache. The issues associated with this PR are bugs that need to be addressed. Thanks again!

@hwillson hwillson closed this Jan 2, 2019
@tobobo
Copy link
Author

tobobo commented Jan 2, 2019

Thanks for the reply and clarification @hwillson !

Under what circumstances would these errors be retrieved from the cache? I've made a minimal reproduction of the behavior I've encountered which I believe demonstrates that the documentation here is confusing if not incorrect.

https://codesandbox.io/s/qqqzp95vq9

The gist of the issue is demonstrated here:

  const firstResult = await apolloClient.query({
    query,
    errorPolicy: "all"
  });
  console.log("First result data:", firstResult.data);
  console.log("First result error:", firstResult.errors[0].message);
  const secondResult = await apolloClient.query({
    query,
    errorPolicy: "all"
  });
  console.log("second result data:", secondResult.data);
  console.log("second result has errors?", !!secondResult.errors);

The first result has the error thrown in the resolver, but the second result has no errors at all, which could cause problems if a particular error UI needs to be rendered in response to the error. Is there something specific that must be done for the errors to be retrieved from the query store? If so, perhaps the documentation should be updated to clarify how to achieve this.

@joepuzzo
Copy link

@tobobo Is this still an issue? Every thread/issue i read about this does not have a clear solution or explanation.

@tobobo
Copy link
Author

tobobo commented Mar 28, 2019

@joepuzzo I've just updated the sandbox above to use the latest versions of all packages and the errors still persist. @hwillson are there any updates on this? The functionality still seems to differ pretty clearly from what's mentioned in the docs, which will be confusing for anyone interested in trying different error policies.

@coderas
Copy link

coderas commented Jun 4, 2019

Got to say, this phrasing had me going around in circles too. Can we update the docs ?

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 17, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants