Warehouse / Guides
Sorting
Sort lists with sortKey and reverse.
Sort a connection
Many connection fields accept sortKey and reverse. The sort key is an enum specific to that field, so follow its linked type to see all valid values.
query Orders($first: Int!, $sortKey: OrdersSortKey!, $reverse: Boolean!) {
orders(first: $first, sortKey: $sortKey, reverse: $reverse) {
edges { node { id reference } }
}
}{
"first": 25,
"sortKey": "ID",
"reverse": true
}Stable pagination
Keep the same sortKey, direction, and search query while following cursors. Changing the ordering between pages can produce gaps or duplicates.
Sort keys and the default order differ per connection; the reference lists them per operation.