Query
product
Retrieves a single product by its unique identifier. Returns null if the product does not exist or has been discontinued.
Signature
query { product(id: ID!): Product }
Arguments
| Name | Type | Required | Description |
|---|---|---|---|
id |
ID! |
Yes | The unique identifier of the product |
Return Type
Product
Complexity: 1
Examples
Query
query GetProduct($id: ID!) {
product(id: $id) {
id
name
description
price
stockQuantity
category {
id
name
}
createdAt
updatedAt
}
}
Variables
{
"id": "prod_abc123"
}
Response
{
"data": {
"product": {
"id": "prod_abc123",
"name": "Wireless Bluetooth Headphones",
"description": "Premium noise-cancelling headphones with 30-hour battery life",
"price": "149.99",
"stockQuantity": 250,
"category": {
"id": "cat_electronics",
"name": "Electronics"
},
"createdAt": "2024-01-15T10:30:00Z",
"updatedAt": "2024-06-20T14:45:30Z"
}
}
}