fix: Make calls of the refetch() & fetchMore() trigger loading state #1366
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.
Description
This PR makes call of the
refetch()
orfetchMore()
triggerloading.value
to change.Motivation
First, this issue.
Second, in the previous version of vue-apollo,
$apollo.queries["query-name"].loading
was changed every time when we callfetchMore()
/refetch()
or just changed values of the variables. And such behavior was very handy, reliable and expectable.Now, call of the
refetch()
setstrue
intoloading.value
, but doesn't setfalse
when refetching is complete.fatchMore()
doesn't change value ofloading.value
at all.Enabling
notifyOnNetworkStatusChange
option is not a good idea, bc on the same page we can have several components and if both of them enable suchnotifyOnNetworkStatusChange
, both will show their loading states while only one component was callingrefetch()
/fetchMore()
etc.Loading state in one component has to stay independent from loading states of other components.
Testing notes
All tests are passed.
I checked @vue/apollo-composable with this fix in my project and everything works as expected.