Skip to content
This repository was archived by the owner on Sep 30, 2024. It is now read-only.
This repository was archived by the owner on Sep 30, 2024. It is now read-only.

Our GraphQL pagination types are a year out of date #5982

Open
@emidoots

Description

@emidoots

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/

Metadata

Metadata

Assignees

No one assigned

    Labels

    apiSourcegraph GraphQL APIdebtTechnical debt.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions