Offset based pagination

schema-request

#1

The pagination in the v4 api uses cursor based pagination (before and after). There seems to be no support for offset based pagination.

This is important in some cases such as sorted search, where we want to paginate based on updated packages.


#2

Hi @Secretmapper,

Cursor based pagination is part of the Relay specification, which we use for GitHub’s V4 API. Could you expand on some of the use cases you’d need to paginate over search and why a cursor may not work?

:bowing_man: much thanks,
Brooks


#3

Hello @bswinnerton, I know you guys are working hard for GH API v4, so thanks for taking the time to read this!

Offset/page based navigation can allow interactions like jump to page, similar to how GitHub’s pagination works.

Due to Relay’s opaque cursor design, interactions like jump to page) is not possible without a specific field.

The reason why I posted this was because I was trying to implement a pagination UI similar to that of Github’s through the API, but realized I couldn’t. I have since then removed jump to page, and resorted to infinite scrolling (which opaque cursors are perfect for).

I guess now that I think about it, there’s really not much use for page-based navigation (at least I can’t think of any) for Github Search results, unless through some weird use case such as ‘query the top 20 - top 30 packages’. So I’ll just leave this up to you guys if you want to implement it.

TLDR: This should allow ‘jump to page’ interactions. But now that I think about it jump to ‘page’ might not be that important though YMMV


#4

+1 for offset based pagination.


#5

+1 for offset pagination. Chaining using cursor is cumbersome…


#6

+1 for offset. The REST API allows to fetch multiple pages of results in parallel thanks to offset. It is no longer possible with GraphQL. This forces us to do multiple page fetching in series which is extremely slow.