Mutation
createProduct
Creates a new product in the catalogue. Requires administrative privileges. The product is created in DRAFT status by default.
Signature
mutation { createProduct(input: CreateProductInput!): CreateProductPayload! }
Arguments
| Name | Type | Required | Description |
|---|---|---|---|
input |
CreateProductInput! |
Yes | Product creation input containing all required product details |
Return Type
CreateProductPayload!
Complexity: 3
Examples
Query
mutation CreateProduct($input: CreateProductInput!) {
createProduct(input: $input) {
product {
id
name
price
stockQuantity
status
createdAt
}
errors {
field
message
}
}
}
Variables
{
"input": {
"name": "Premium Wireless Mouse",
"description": "Ergonomic wireless mouse with precision tracking",
"price": "79.99",
"stockQuantity": 100,
"categoryId": "cat_computers",
"sku": "MOUSE-WL-001"
}
}
Response
{
"data": {
"createProduct": {
"product": {
"id": "prod_new789",
"name": "Premium Wireless Mouse",
"price": "79.99",
"stockQuantity": 100,
"status": "DRAFT",
"createdAt": "2024-06-21T15:00:00Z"
},
"errors": null
}
}
}