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

v4: Using fetchMore and then refetch causes duplicated results. #1026

Open
Tracked by #9504
MechJosh0 opened this issue Jul 31, 2020 · 5 comments
Open
Tracked by #9504

v4: Using fetchMore and then refetch causes duplicated results. #1026

MechJosh0 opened this issue Jul 31, 2020 · 5 comments

Comments

@MechJosh0
Copy link

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 MechJosh0 changed the title Using fetchMore and then refetch causes duplicated results. v4: Using fetchMore and then refetch causes duplicated results. Jul 31, 2020
@Akryum Akryum added the v4 label Oct 15, 2020
@Jesseyx
Copy link

Jesseyx commented Mar 5, 2021

Have the same issue!

@Akryum
Copy link
Member

Akryum commented Apr 2, 2021

Are you using Apollo Client 3 or 2?

@Jesseyx
Copy link

Jesseyx commented Apr 7, 2021

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

@Akryum Akryum added the upstream label Apr 7, 2021
@Akryum
Copy link
Member

Akryum commented Apr 7, 2021

Maybe related to apollographql/apollo-client#6916

@dominikklein
Copy link
Contributor

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants