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

Pagination using useSuspenseQuery gets empty array instead of cached array when api response with empty array #11702

Closed
geniusgordon opened this issue Mar 19, 2024 · 4 comments

Comments

@geniusgordon
Copy link

geniusgordon commented Mar 19, 2024

Issue Description

I am trying to do pagination with useSuspenseQuery and typePolicies.

I've made a reproduction in stackblitz to better describe the issue: https://stackblitz.com/~/github.com/geniusgordon/stackblitz-starters-8ms1yj
(The example is forked from #11315)

I copied the merge function from offsetLimitPagination so that I can add some console.log.

After clicking "fetch more" multiple times, incoming will be an empty array when there are no items left, and the data returned from useSuspenseQuery becomes an empty array instead of the cached array which is the value returned in the merge function.

I tried useQuery as well, and it works normally.

Link to Reproduction

https://stackblitz.com/~/github.com/geniusgordon/stackblitz-starters-8ms1yj

Reproduction Steps

  1. open the stackblitz link
  2. click "fetch more" 3 or 4 times
  3. Look at the logs

@apollo/client version

3.9.7

@jerelmiller
Copy link
Member

Hey @geniusgordon 👋

Thanks for the reproduction! I believe this is a similar issue as #11642. I'll keep this open so that I can test a fix against this reproduction as well. Appreciate the report!

@jerelmiller jerelmiller self-assigned this Mar 19, 2024
@jerelmiller
Copy link
Member

I changed my mind, I'm going to track this over in #11642 since the reproduction here looks similar to the one in that issue. Watch that issue for updates on this bug. Thanks!

@jerelmiller jerelmiller closed this as not planned Won't fix, can't repro, duplicate, stale Mar 19, 2024
Copy link
Contributor

Do you have any feedback for the maintainers? Please tell us by taking a one-minute survey. Your responses will help us understand Apollo Client usage and allow us to serve you better.

Copy link
Contributor

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
For general questions, we recommend using StackOverflow or our discord server.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 19, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants