apollo icon indicating copy to clipboard operation
apollo copied to clipboard

v4: Using fetchMore and then refetch causes duplicated results.

Open MechJosh0 opened this issue 4 years ago • 5 comments

Describe the bug Using fetchMore and then refetch causes duplicated results.

To Reproduce Steps to reproduce the behavior:

  1. Load results from backend using useQuery
  2. Use fetchMore to load the next page
  3. 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 1 refetch will not reproduce the bug
    • You must produce this bug on the first refetch you perform, any following refetch 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

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).

MechJosh0 avatar Jul 31 '20 07:07 MechJosh0

Have the same issue!

Jesseyx avatar Mar 05 '21 08:03 Jesseyx

Are you using Apollo Client 3 or 2?

Akryum avatar Apr 02 '21 15:04 Akryum

Versions @apollo/client: 3.3.11 @vue/apollo-composable: 4.0.0-alpha.12 vue: 3.0.5

Jesseyx avatar Apr 07 '21 07:04 Jesseyx

Maybe related to https://github.com/apollographql/apollo-client/issues/6916

Akryum avatar Apr 07 '21 08:04 Akryum

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.

dominikklein avatar Oct 17 '22 11:10 dominikklein