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

Retain previous result when partialRefetching #6012

Closed
wants to merge 5 commits into from

Conversation

glentakahashi
Copy link

@glentakahashi glentakahashi commented Mar 3, 2020

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

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

@codecov
Copy link

codecov bot commented Mar 5, 2020

Codecov Report

Merging #6012 into master will not change coverage by %.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##           master    #6012   +/-   ##
=======================================
  Coverage   95.20%   95.20%           
=======================================
  Files          88       88           
  Lines        3674     3674           
  Branches      873      903   +30     
=======================================
  Hits         3498     3498           
  Misses        154      154           
  Partials       22       22           

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update e9be4be...f171ce8. Read the comment docs.

@glentakahashi
Copy link
Author

@benjamn or @hwillson Sorry to ping, but this ticket has been open a while and was curious if you had thoughts or opinions on mergeability

@glentakahashi
Copy link
Author

Actually it appears as if this bug was fixed in #6221.

Now it appears that when refetching, the component with partialRefetch: true won't re-render until the refetch has completed unless it has returnPartialData set as true

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 16, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant