apollographql / apollo-client

:rocket:  A fully-featured, production ready caching GraphQL client for every UI framework and GraphQL server.
https://apollographql.com/client
MIT License
19.38k stars 2.66k forks source link

Implement Server-Side Pagination in Next.js with Apollo Client #11765

Closed berzhavycha closed 6 months ago

berzhavycha commented 7 months ago

Is it feasible to enable server-side pagination exclusively in Next.js using Apollo Client? Apollo Client provides @apollo/experimental-nextjs-app-support for Next.js app client management. However, a question arises: Can pagination be solely implemented on the server side? My understanding suggests it may not be viable because each request from the server component generates a new client instance, hindering the merging of items for pagination. Does this limitation imply that pagination can only be achieved through client-side data fetching? Alternatively, are there potential workarounds to address this issue?

phryneas commented 7 months ago

It depends solely on what you mean by "pagination".

In the classic meaning of "displaying one page only", yes, that can be achieved with Next.js RSC, as you don't need to merge with previous data for that.
If you mean "infinite scrolling": As far as I'm aware there's no way of doing that with RSC at all, independently of Apollo Client.

github-actions[bot] commented 6 months ago

We're closing this issue now but feel free to ping the maintainers or open a new issue if you still need support. Thank you!

github-actions[bot] commented 5 months ago

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.