CartLinesUpdateInput
Input for a cart line item used to update the quantity and customizations of merchandise within a cart.
Input Definition
input CartLinesUpdateInput {
id: Int!
quantity: Int!
customizations: [CustomizationGroupOptionInput]
}
Fields
Field | Type | Required | Description | Default Value |
---|---|---|---|---|
id | Int! | Yes | The ID of the cart line item to update | N/A |
quantity | Int! | Yes | The quantity of the merchandise item to update | N/A |
customizations | [CustomizationGroupOptionInput] | No | List of customizations for the merchandise item | None |
Usage Examples
Basic Usage
mutation {
updateCartLines(input: {
id: 12345
quantity: 3
}) {
cart {
id
lines {
id
quantity
}
}
}
}
Complex Input
mutation {
updateCartLines(input: {
id: 12345
quantity: 5
customizations: [
{
groupId: 10
optionId: 25
},
{
groupId: 12
optionId: 30
}
]
}) {
cart {
id
lines {
id
quantity
customizations {
groupId
optionId
}
}
}
}
}
With Variables
mutation UpdateCartLine($input: CartLinesUpdateInput!) {
updateCartLines(input: $input) {
cart {
id
lines {
id
quantity
customizations {
groupId
optionId
}
}
}
}
}
Variables:
{
"input": {
"id": 12345,
"quantity": 2,
"customizations": [
{
"groupId": 10,
"optionId": 25
}
]
}
}
Nested Objects
mutation {
updateCartLines(input: {
id: 12345
quantity: 4
customizations: [
{
groupId: 15
optionId: 40
}
]
}) {
cart {
id
lines {
id
quantity
customizations {
groupId
optionId
}
}
}
}
}
Validation Rules
id
must be a positive integer identifying an existing cart line item.quantity
must be a positive integer greater than zero.customizations
, if provided, must be an array of validCustomizationGroupOptionInput
objects.- Each
CustomizationGroupOptionInput
must include validgroupId
andoptionId
integers corresponding to available customization options. - Omitting
customizations
will leave the current customizations unchanged. - Setting
quantity
to zero is invalid; use a separate mutation to remove a cart line.
Error Examples
- Missing required field
id
:
{
"errors": [
{
"message": "Field 'id' of required type 'Int!' was not provided.",
"locations": [{ "line": 2, "column": 15 }]
}
]
}
- Invalid
quantity
value (e.g., zero or negative):
{
"errors": [
{
"message": "Quantity must be a positive integer greater than zero.",
"locations": [{ "line": 3, "column": 17 }]
}
]
}
- Invalid
customizations
format:
{
"errors": [
{
"message": "Each customization must include valid 'groupId' and 'optionId' integers.",
"locations": [{ "line": 4, "column": 20 }]
}
]
}
Best Practices
- Always provide both
id
andquantity
fields when updating a cart line. - Use the
customizations
field only when you need to update or add customization options; omit it to keep existing customizations. - Validate
quantity
on the client side to ensure it is a positive integer before sending the request. - Use GraphQL variables to improve readability and reusability of your mutations.
- When updating multiple cart lines, send separate mutations or batch them if supported by your API.
- Avoid setting
quantity
to zero; use dedicated removal mutations to delete cart lines. - Confirm that
groupId
andoptionId
values correspond to valid customization options available for the merchandise.
Related Types
CustomizationGroupOptionInput
: Input type representing a customization option group and selected option.
Notes
- This API currently requires no authentication, but this may change in future versions.
- The
CartLinesUpdateInput
type is designed for updating existing cart line items only. - Proper error handling is recommended to manage validation errors and ensure a smooth user experience.
- Use this input type as part of mutations that update cart contents, such as
updateCartLines
or similar operations.
Last updated on