Skip to content

Update FilteredConnection to support forward direction cursor-paging

Warren Gifford requested to merge ef/forward-pagination into master

Created by: efritz

This introduces additional functionality into FilteredConnection to support forward-only cursor paging. This functionality will be necessary for RFC 46 and possibly RFC 23.

The legacy pagination supported by FilteredConnection simply doubles the first parameter on each subsequent request, which acts as an increasing limit. This increases the time required in the backend to fetch increasingly large result sets.

This change detects if an endCursor is present in the PageInfo of the GraphQL response. If so, the subsequent request is given this value as its after argument, as described in the docs.

If cursor-based pagination is used, subsequent results are (optionally) appended to the current set of results to produce an infinite-scroll pagination. This is the smallest change that supports cursor-based pagination without requiring additional UX work to ensure that the item counts are not problematic (X total, showing first Y).

In the future, we'll want a more in-depth discussion in order to support forward and backward cursor-based paging that has a more accurate item count description, and updated URL parameters that allow you to jump directly to a result page (the after parameter is explicitly omitted from the URL in this effort, as we don't have an easy way to determine how many items we've skipped when given an opaque after ID).

Merge request reports

Loading