TECHNOLOGY

Relay backward pagination preserves the connection’s edge order

In this article
THE QUICK TAKE

Keep connection ordering stable in both directions, use the appropriate boundary cursor and avoid inferring the opposite direction’s completeness from an optional PageInfo signal.

Select an earlier window without reversing it

A research interface shows a connection of source revisions and lets the reader move backward through older pages. The Cursor Connections specification requires the same edge ordering for forward and backward pagination when other arguments are equal. last and before select a preceding window; they do not instruct the server to reverse that window’s edges. A client that reverses again can display an inconsistent sequence when joining pages.

Use the boundary belonging to the direction

The GitHub GraphQL guide demonstrates forward traversal with endCursor and after, and backward traversal with startCursor and before. Keep the query’s connection and selection arguments aligned. An edge cursor describes a position in that connection; it should not be replaced by a node identifier or reused under different ordering assumptions merely because the same node appears in another list.

Keep cursors opaque at the client boundary

The GraphQL pagination guide explains that a cursor is a property of the edge in the connection. Encoding that looks decodable does not authorize client reconstruction of another position. Store the returned string and use it under the same connection contract. The client needs the position token’s role, not an inferred internal database key or offset that the server can change without redesigning the connection interface.

Read PageInfo in the active direction

The specification gives stronger requirements for hasNextPage while moving forward and hasPreviousPage while moving backward. The opposite-direction flag may report false when determining that information efficiently is not possible. Do not infer that a forward page with a false previous-page flag necessarily starts at the collection’s beginning. Use the guarantee associated with the chosen traversal when deciding whether to continue or disable a navigation control.

Join pages using the declared edge sequence

Preserve returned edge order when appending a later window or placing an earlier window before the current one. Task contracts define the intended revision view; tool observations retain query direction, boundary and PageInfo. This makes backward navigation a precise connection operation without turning opaque cursors into object identities, reversing the server’s agreed order or presenting optional opposite-direction information as a complete inventory guarantee.

Earn rental income from GPUs

Have idle GPUs or looking to fund AI infrastructure? Retrivium finds a rental platform, sets up the server and helps you assess income and costs with a pilot.

Explore GPU hosting
← All articles