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

Always throw network errors in useSupenseQuery regardless of the error policy #10401

Merged

Conversation

jerelmiller
Copy link
Member

Closes #10384

Updates useSuspenseQuery to always throw network errors, regardless of the errorPolicy set in options. This is more in-line with how useQuery works when encountering a network error since the error is retained and the onError callback is called.

Checklist:

  • If this PR is a new feature, please reference an issue where a consensus about the design was reached (not necessary for small changes)
  • Make sure all of the significant new logic is covered by tests

@changeset-bot
Copy link

changeset-bot bot commented Jan 3, 2023

🦋 Changeset detected

Latest commit: 94c57f8

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@apollo/client Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@jerelmiller jerelmiller changed the base branch from main to release-3.8 January 3, 2023 22:22
@jerelmiller jerelmiller force-pushed the always-throw-network-errors-usesuspensequery branch from 29d1383 to 94c57f8 Compare January 4, 2023 00:13
if (
result.error &&
errorPolicy === 'none' &&
const allowsThrownErrors =
Copy link
Member Author

@jerelmiller jerelmiller Jan 4, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The logic felt a bit heavy when reading this all inside the if below. That being said, there are so many names here, its hard to keep coming up with new ones. If you have a suggestion for a better name for this variable, I'd love to hear it! At the very least, I want to make sure the if statement below reads nicely and is easily understandable. If not, please let me know how I can update this to make it easier to understand the logic here.

Copy link
Member

@alessbell alessbell left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@jerelmiller jerelmiller merged commit 3e5b41a into release-3.8 Jan 4, 2023
@jerelmiller jerelmiller deleted the always-throw-network-errors-usesuspensequery branch January 4, 2023 19:31
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 11, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

useSuspenseQuery should always throw network errors regardless of error policy
2 participants