-
Notifications
You must be signed in to change notification settings - Fork 786
Fix always loading issue caused by error handling #3107
Conversation
The React Apollo `Query` component relies on Apollo Client's `ObservableQuery->getCurrentResult` method to get the results of a query to display. When `ObservableQuery` encounters an error, it stores that error in its associated query store, so that it can be passed back to React Apollo for handling. Unfortunately, the error stored in the query store isn't cleared out until a component unmounts, which means components that handle an error response followed by a valid response, won't get the chance to render the valid response. They're stuck rendering the error state, since the error stored in the `ObservableQuery` query store is never removed. This commit calls into a new `ObservableQuery.resetQueryStoreErrors` method, to clear out previously used errors, before moving on to handle subsequent responses. This means a component can handle an error, then receive and display a valid subsequent response. Fixes: #3090
@jasonpaulos Definitely! I have it ready (I just haven't committed it yet). I should have it in the RA 3 branch shortly. As soon as it's there, I'm then planning on publishing a final version of RA 2, then will merge the RA 3 branch into |
any updates on when the final version of RA 2 will be published with this fix? |
@sambaek I believe it was just published as 2.5.7 |
I was using 2.5.6 and it was getting stuck. Im using a Query in my HOC to reject the user to the login if not logged in. Now it seems to make several repeated calls to the API for checking. What gives?
|
Hi @developdeez, could you create a new issue with this bug? It would also help a lot if you could provide a runnable reproduction that shows this. Thanks. |
The React Apollo
Query
component relies on Apollo Client'sObservableQuery->getCurrentResult
method to get the results of a query to display. WhenObservableQuery
encounters an error, it stores that error in its associated query store, so that it can be passed back to React Apollo for handling. Unfortunately, the error stored in the query store isn't cleared out until a component unmounts, which means components that handle an error response followed by a valid response, won't get the chance to render the valid response. They're stuck rendering the error state, since the error stored in theObservableQuery
query store is never removed.This commit calls into a new
ObservableQuery.resetQueryStoreErrors
method, to clear out previously used errors, before moving on to handle subsequent responses. This means a component can handle an error, then receive and display a valid subsequent response.Fixes: #3090
Note: This PR is dependent on apollographql/apollo-client#4941 being merged.