-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixes issue where refetching an error after an error was returned wou…
…ld hang on loading state (#11180) When an error is thrown by `useReadQuery` for a query kicked off by `useBackgroundQuery`, you can try fetching the query again using the `refetch` function. The network request would be properly kicked off, but if the result of the refetch contained another error, the hook would get stuck in the loading state. This was due to the subscription to `ObservableQuery` from `QueryReference` getting cleaned up when the `observer.error` function was run. The only reason the hook works today when refetching after an error with a successful result is because we have some [code](https://github.com/apollographql/apollo-client/blob/1c74ed4e3dc5feb5537b2aac30ab9d730fca0342/src/react/cache/QueryReference.ts#L285-L289) that catches cases where successful results could still be reported back to the hook --------- Co-authored-by: Lenz Weber-Tronic <[email protected]>
- Loading branch information
1 parent
6b81981
commit 7d9c481
Showing
7 changed files
with
299 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"@apollo/client": patch | ||
--- | ||
|
||
Fixes an issue where refetching from `useBackgroundQuery` via `refetch` with an error after an error was already fetched would get stuck in a loading state. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters