Mutation
updateOrderStatus
Updates the status of an order. Valid transitions are: PENDING→CONFIRMED→SHIPPED→DELIVERED or PENDING→CANCELLED. Returns the updated order with status history.
Signature
mutation { updateOrderStatus(id: ID!, status: OrderStatus!, note: String): UpdateOrderStatusPayload! }
Arguments
| Name | Type | Required | Description |
|---|---|---|---|
id |
ID! |
Yes | The unique identifier of the order to update |
status |
OrderStatus! |
Yes | The new order status |
note |
String |
No | Optional note explaining the status change |
Return Type
UpdateOrderStatusPayload!
Complexity: 3
Examples
Query
mutation UpdateOrderStatus($id: ID!, $status: OrderStatus!, $note: String) {
updateOrderStatus(id: $id, status: $status, note: $note) {
order {
id
status
statusHistory {
status
changedAt
note
}
updatedAt
}
previousStatus
errors {
field
message
}
}
}
Variables
{
"id": "order_abc123",
"status": "SHIPPED",
"note": "Dispatched via express courier"
}
Response
{
"data": {
"updateOrderStatus": {
"order": {
"id": "order_abc123",
"status": "SHIPPED",
"statusHistory": [
{
"status": "PENDING",
"changedAt": "2024-06-20T10:00:00Z",
"note": null
},
{
"status": "CONFIRMED",
"changedAt": "2024-06-20T10:15:00Z",
"note": "Payment verified"
},
{
"status": "SHIPPED",
"changedAt": "2024-06-21T09:30:00Z",
"note": "Dispatched via express courier"
}
],
"updatedAt": "2024-06-21T09:30:00Z"
},
"previousStatus": "CONFIRMED",
"errors": null
}
}
}