apollo
apollo copied to clipboard
v4: Using fetchMore and then refetch causes duplicated results.
Describe the bug
Using fetchMore
and then refetch
causes duplicated results.
To Reproduce Steps to reproduce the behavior:
- Load results from backend using
useQuery
- Use
fetchMore
to load the next page - Perform a search on the results using
refetch
- You must only trigger
refetch
once, so if you're using a search input you should paste the search query in. Typing a query manually and performing more than 1refetch
will not reproduce the bug - You must produce this bug on the first
refetch
you perform, any followingrefetch
calls will not reproduce the bug - The bug will only be reproducible on the first time you do it, to reproduce it again you have to reload
- The found item does not have to be in memory, reproducible either way
- You must only trigger
What happens
The results found are duplicated from useQuery
.
Expected behaviour
The results should only be what was discovered from the Graph call to the backend that came from your refetch
call.
Versions vue: 2.6.11 vue-apollo: v4.0.0-alpha.10 apollo-client: 2.6.10
Additional context
During the steps to reproduce, if you watch
the Ref result
from useQuery
you will notice how result
changes twice. The first instance will be the correct value and the second time it's the incorrect value due to duplicated items.
You will also notice that when you perform your refetch
it will only do one Graph backend call, which is expected. The results returned from the server are the correct results. Only one Graph call is perform but watching result
from useQuery
is still triggered twice with the correct and then incorrect value).
Have the same issue!
Are you using Apollo Client 3 or 2?
Versions @apollo/client: 3.3.11 @vue/apollo-composable: 4.0.0-alpha.12 vue: 3.0.5
Maybe related to https://github.com/apollographql/apollo-client/issues/6916
I think it's not completely related to this bug.
Currently, I have also a problem in that my watcher on the result is triggered twice when I use the refetch
.
In the code, I saw that there is a processOnResult
triggered directly from the refetch
function and also from the onNextResult
, when something really changed in the result or a "no cache" policy is used.