# Fetches the 5 latest purchase orders for the
# current user, and the first 8 orderlines for
# each purchase order.
query myOrders {
purchaseOrders(limit:5, orderBy: {createdAt:desc}){
purchaseOrderId
createdAt
orderStatus
# This fetches orderlines for the purchase
# order, but does not cause multiple fetches,
# round-trips or the N+1 problem.
orderLines(limit: 8 orderBy: { orderLineId: desc})
{
unitPrice
quantity
product {
productId
description
}
}
}
}
{
"data": {
"purchaseOrders": [
{
"purchaseOrderId": 581796,
"createdAt": "2023-08-21T10:38:19.952764+00:00",
"orderStatus": "NEW",
"orderLines": [{
"unitPrice": "0.12", "quantity": 1,
"product": { "productId": 134, "description": "DISCO BALL CHRISTMAS DECORATION" }
}]
},
{
"purchaseOrderId": 581795,
"createdAt": "2023-08-21T10:37:22.637079+00:00",
"orderStatus": "NEW",
"orderLines": [{
"unitPrice": "0.21", "quantity": 1,
"product": { "productId": 28, "description": "ANIMAL STICKERS" }
}]
}
]
}
}