Logo
NeoArc Studio
Mutation

createOrder

Creates a new order for a customer. The order is initially created in PENDING status and must have at least one item. Stock is reserved upon order creation.

Tags: orders, checkout

Signature

mutation { createOrder(input: Unknown!): CreateOrderPayload! }

Arguments

Name Type Required Description
input Unknown! Yes The order creation input containing customer ID, items, and shipping details

Return Type

CreateOrderPayload!

Complexity: 5

Examples

Query

mutation CreateOrder($input: CreateOrderInput!) {
  createOrder(input: $input) {
    order {
      id
      status
      totalAmount
      items {
        product {
          id
          name
        }
        quantity
        unitPrice
      }
    }
    errors {
      field
      message
    }
  }
}

Variables

{
  "input": {
    "customerId": "cust_xyz789",
    "items": [
      {
        "productId": "prod_abc123",
        "quantity": 2
      },
      {
        "productId": "prod_def456",
        "quantity": 1
      }
    ],
    "shippingAddressId": "addr_001"
  }
}

Response

{
  "data": {
    "createOrder": {
      "order": {
        "id": "order_new456",
        "status": "PENDING",
        "totalAmount": "319.97",
        "items": [
          {
            "product": {
              "id": "prod_abc123",
              "name": "Wireless Bluetooth Headphones"
            },
            "quantity": 2,
            "unitPrice": "149.99"
          },
          {
            "product": {
              "id": "prod_def456",
              "name": "USB-C Charging Cable"
            },
            "quantity": 1,
            "unitPrice": "19.99"
          }
        ]
      },
      "errors": null
    }
  }
}