Provide a previousData property in useQuery/useLazyQuery results #7082
+322
−34
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.
Alongside their returned
data
property,useQuery
anduseLazyQuery
now also return apreviousData
property. Before a newdata
value is set, its current value is stored inpreviousData
. This allows more fine-grained control over component loading states, where developers might want to leverage previous data until new data has fully loaded.@benjamn just a heads up that I did look into moving the
previousData
handling up the chain into the ACcore
itself. The amount of work needed to get this functionality in place would have been more substantial however (as thelastResult
tracking we’re doing inObservableQuery
doesn’t quite line up with what we’re looking for here), so I’ve left it in the React layer for now (where we were already trackingpreviousData
, but just not exposing it). This should address most of the oustanding issues around this functionality, and we can always consider this a stepping stone. Changing how this works internally in the future will be hidden fromuseQuery
/useLazyQuery
consumers. Thanks!Fixes #6603