-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
Throw errors returned from incremental chunks when error policy is none
#11032
Changes from all commits
db58fc1
5e79131
401aaab
22b695c
110d982
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
--- | ||
'@apollo/client': patch | ||
--- | ||
|
||
Throw errors in `useSuspenseQuery` for errors returned in incremental chunks when `errorPolicy` is `none`. This provides a more consistent behavior of the `errorPolicy` in the hook. | ||
|
||
### Potentially breaking change | ||
|
||
Previously, if you issued a query with `@defer` and relied on `errorPolicy: 'none'` to set the `error` property returned from `useSuspenseQuery` when the error was returned in an incremental chunk, this error is now thrown. Switch the `errorPolicy` to `all` to avoid throwing the error and instead return it in the `error` property. |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -201,10 +201,7 @@ export class InternalQueryReference<TData = unknown> { | |
return; | ||
} | ||
|
||
this.result = result; | ||
this.promise = result.data | ||
? createFulfilledPromise(result) | ||
: createRejectedPromise(result); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Turns out we never reached this case before! We were throwing the entire result as the error rather than the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If we never reached this before, why do we reach it now? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Perhaps I'm making too much of an assumption with that claim. The reason I feel this way because this was throwing the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. FYI, I'll be refactoring this logic anyways in likely my next PR, so expect this stuff to change and work more robustly. I had to get this change in there first to help that refactor. |
||
this.promise = createRejectedPromise(error); | ||
this.deliver(this.promise); | ||
} | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's not clear in this diff, but
this.result
is set above in this same function. This removes the unneeded duplication.