Query
order
Retrieves a single order by its unique identifier. Users can only access their own orders unless they have administrative privileges.
Signature
query { order(id: ID!): Order }
Arguments
| Name | Type | Required | Description |
|---|---|---|---|
id |
ID! |
Yes | The unique identifier of the order |
Return Type
Order
Complexity: 2
Examples
Query
query GetOrder($id: ID!) {
order(id: $id) {
id
status
customer {
id
email
firstName
lastName
}
items {
id
product {
id
name
price
}
quantity
unitPrice
subtotal
}
shippingAddress {
street
city
postcode
country
}
subtotal
shippingCost
tax
totalAmount
createdAt
updatedAt
}
}
Variables
{
"id": "order_abc123"
}
Response
{
"data": {
"order": {
"id": "order_abc123",
"status": "CONFIRMED",
"customer": {
"id": "cust_xyz789",
"email": "[email protected]",
"firstName": "John",
"lastName": "Doe"
},
"items": [
{
"id": "item_001",
"product": {
"id": "prod_abc123",
"name": "Wireless Bluetooth Headphones",
"price": "149.99"
},
"quantity": 2,
"unitPrice": "149.99",
"subtotal": "299.98"
}
],
"shippingAddress": {
"street": "123 High Street",
"city": "London",
"postcode": "SW1A 1AA",
"country": "GB"
},
"subtotal": "299.98",
"shippingCost": "5.99",
"tax": "61.19",
"totalAmount": "367.16",
"createdAt": "2024-06-20T10:00:00Z",
"updatedAt": "2024-06-20T10:05:00Z"
}
}
}