apollographql/apollo-client

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

berzhavycha opened this issue · 2 comments

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?

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.