GraphQL API
Organization API
Organization guide

Sorting

Choose a supported sort key and control the result direction.

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.

Do not assume every connection supports the same keys or default ordering. Check the operation.