Skip to content

Our GraphQL pagination types are a year out of date

Created by: slimsag

PageInfo type

While looking to use PageInfo for search pagination, I found we already have a PageInfo type:

https://github.com/sourcegraph/sourcegraph/blob/a7bb16a9b3e981fa6382aacb3fd33badbea80cb7/cmd/frontend/graphqlbackend/schema.graphql#L1965-L1969

But it only contains hasNextPage and doesn't contain any notion of cursors of previous pages as the link in the docstring does: https://facebook.github.io/relay/graphql/connections.htm#sec-undefined.PageInfo

In fact, it doesn't even match the "Relay Legacy" definition, which -- quoting the docs -- contains cursors and edges still:

Relay Legacy did not define startCursor and endCursor, and relied on selecting the cursor of each edge; Relay Modern began selecting startCursor and endCursor instead to save bandwidth (since it doesn’t use any cursors in between).

Connection objects

According to the Relay Modern specification, connection types must contain an edges field: https://facebook.github.io/relay/graphql/connections.htm#sec-Edges

Our connection objects only declare nodes, even in recently added APIs like campaigns:

https://github.com/sourcegraph/sourcegraph/blob/a7bb16a9b3e981fa6382aacb3fd33badbea80cb7/cmd/frontend/graphqlbackend/schema.graphql#L432-L433

Using GitHub's API as a reference, it appears we should have both nodes and edges:

https://developer.github.com/v4/object/marketplacelistingconnection/