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

Use pagination from cache instead of react state #483

Open
hiagolcm opened this issue Jan 25, 2021 · 1 comment
Open

Use pagination from cache instead of react state #483

hiagolcm opened this issue Jan 25, 2021 · 1 comment

Comments

@hiagolcm
Copy link
Contributor

Is your feature request related to a problem? Please describe.

Describe the solution you'd like
This bug is happening because the apollo client is caching the paginated result. In other words, when you navigate to the Apparel & Accessories` again, the react apollo returns the page 1 and 2.

To solve this problem, we need to save the pagination on the cache instead of using the pageState

The step by step to solve this is:

  1. Add from and to to the productSearch schema
  2. Return the proper from and to on all search resolvers
  3. Add from and to to the searchResultV3
  4. Change the search-result to use the from and to from the query instead of the pageState
@razvanudream
Copy link

razvanudream commented Nov 8, 2021

Hi. This is still happening, any fixes yet? I'm using this configuration and still getting the duplicated products on fetchMore

"context": { "hideUnavailableItems": true, "skusFilter": "FIRST_AVAILABLE", "maxItemsPerPage": 12, "orderByField": "OrderByTopSaleDESC", "simulationBehavior": "skip", "__unstableProductOriginVtex":true }

Tried simulationBehaviour: "default" as well and many other things. Tried linking search-result 3.x on a workspace and debug it myself, but seems to be related to the "to" param not being updated properly

#373 - there was an attempt to fix this here but doesn't work, unless I'm missing something.

LE:

After further testing, this seems to be happening only on one account and only when going from first page to second page, then from second page to third page (this step duplicates page 2 results again and stays the same in the URL) after that, it renders the products correctly, but the 2nd page is always duplicated

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

No branches or pull requests

2 participants