OrderingQuery.orders()
type OrderingQuery {
orders(after: String): OrderingOrdersConnection!
}
Returns a list of all orders for the authenticated organization.
after (optional)
String - A cursor value used for pagination. When provided, the query returns orders after the specified cursor. To paginate through results, use the cursor value from the last edge of the previous response.
Example:
query GetOrders {
ordering {
orders(after: "eyJpZCI6IjEyMyJ9") {
edges {
cursor
node {
id
}
}
}
}
}
Response
OrderingOrdersConnection
OrderingOrdersConnection - A connection object containing a list of orders.
OrderingOrdersConnection
type OrderingOrdersConnection {
edges: [OrderingOrdersEdge!]!
}
edges
OrderingOrdersEdge[] - An array of edges, each containing an order node.
OrderingOrdersEdge
type OrderingOrdersEdge {
node: OrderingOrder!
cursor: String!
}
node
OrderingOrder - The order object containing all order details.
cursor
String - A unique cursor value for this edge. Use this value as the after parameter in subsequent queries to fetch the next page of results.
Cursor values should be treated as opaque identifiers. While they may appear numeric in the current implementation, their format is subject to change and should not be parsed or manipulated.
The orders query uses cursor-based pagination, allowing you to efficiently paginate through large sets of orders. Each edge in the response includes a cursor field that can be used to fetch the next set of results.
How It Works
- Make an initial query without the
after parameter to get the first page of results
- Extract the
cursor value from the last edge in the response
- Use that
cursor as the after parameter in your next query to fetch the next page
- Repeat until you’ve retrieved all the orders you need
Example: Paginating Through Orders
Initial Request (First Page):
query GetFirstPageOfOrders {
ordering {
orders {
edges {
cursor
node {
id
status
createdAt
}
}
}
}
}
Response:
{
"data": {
"ordering": {
"orders": {
"edges": [
{
"cursor": "1",
"node": {
"id": "order-123",
"status": "Delivered",
"createdAt": "2024-01-15T10:30:00Z"
}
},
{
"cursor": "2",
"node": {
"id": "order-124",
"status": "In_Transit",
"createdAt": "2024-01-16T14:20:00Z"
}
}
]
}
}
}
}
Subsequent Request (Next Page):
query GetNextPageOfOrders {
ordering {
orders(after: "2") {
edges {
cursor
node {
id
status
createdAt
}
}
}
}
}
This will return the next set of orders after the cursor value “2”.