Retain previous result when partialRefetching #6012
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Checklist:
Version
@apollo/client 3.0.0-beta.38
Right now if a query is marked as partial, during the refresh loading will properly be set to "true" however data is returned as undefined.
This causes undesirable behavior as when a partial refetch is occurring you cannot render the component with the previous data unless you use an external state mechanism like a
useState
to store the value in-between runs.In some cases it might be desirable depending on the use case to show a null or loading state during a partial refetch, but this could be handled by using the
loading
state instead of relying on data being undefined.You can also get around this today by setting
returnPartialData: true
, however that is not desirable in many situations as well.Relates to apollographql/react-apollo#2114
A partial port of apollographql/react-apollo#3606
(apollo-client 3.x fixed the bug causing partialRefetches to not happen, this only ports over setting previousData) cc @minznerjosh