Subscription
newOrder
Subscribes to real-time notifications when new orders are created. Useful for order management dashboards and fulfilment systems. Can optionally filter by customer ID.
Signature
subscription { newOrder(customerId: ID): NewOrderEvent! }
Arguments
| Name | Type | Required | Description |
|---|---|---|---|
customerId |
ID |
No | Optional customer ID to only receive orders for a specific customer |
Return Type
NewOrderEvent!
Complexity: 3
Examples
Query
subscription OnNewOrder($customerId: ID) {
newOrder(customerId: $customerId) {
order {
id
status
totalAmount
customer {
id
email
firstName
lastName
}
items {
product {
id
name
}
quantity
unitPrice
}
createdAt
}
isFirstOrder
}
}
Variables
{
"customerId": null
}
Response
{
"data": {
"newOrder": {
"order": {
"id": "order_xyz789",
"status": "PENDING",
"totalAmount": "199.98",
"customer": {
"id": "cust_abc123",
"email": "[email protected]",
"firstName": "John",
"lastName": "Doe"
},
"items": [
{
"product": {
"id": "prod_abc123",
"name": "Wireless Bluetooth Headphones"
},
"quantity": 1,
"unitPrice": "149.99"
},
{
"product": {
"id": "prod_def456",
"name": "USB-C Charging Cable"
},
"quantity": 2,
"unitPrice": "24.99"
}
],
"createdAt": "2024-06-21T11:00:00Z"
},
"isFirstOrder": false
}
}
}