CartLinesUpdatePayload
Payload returned by the cartLinesUpdate
mutation. This object contains the updated cart after the mutation operation and any user errors that occurred during the update process.
Type Definition
type CartLinesUpdatePayload {
cart: Cart!
userErrors: [UserError]!
}
Fields
Field | Type | Nullability | Description | Relationship |
---|---|---|---|---|
cart | Cart | Non-nullable | The updated cart after the lines update | References the Cart object |
userErrors | [UserError] | Non-nullable | List of errors that occurred during cart lines update | List of UserError objects |
Relationships
- cart: Links to the
Cart
object representing the current state of the cart after the update mutation. - userErrors: An array of
UserError
objects providing detailed information about any issues encountered during the update operation.
Usage Examples
Basic Query
mutation {
cartLinesUpdate(cartId: "eyJhbGciOiJIUzI1NiJ9...", lines: [{id: 98765, quantity: 2}]) {
cart {
id
lines(first: 5) {
edges {
node {
id
quantity
merchandise {
... on ProductVariant {
id
title
}
}
}
}
}
estimatedCost {
totalAmount {
amount
currencyCode
}
}
}
userErrors {
field
message
}
}
}
Field Selection
mutation {
cartLinesUpdate(cartId: "eyJhbGciOiJIUzI1NiJ9...", lines: [{id: 12345, quantity: 3}]) {
cart {
id
totalQuantity
lines(first: 3) {
edges {
node {
id
quantity
}
}
}
}
userErrors {
message
}
}
}
Nested Queries
mutation {
cartLinesUpdate(cartId: "eyJhbGciOiJIUzI1NiJ9...", lines: [{id: 54321, quantity: 1}]) {
cart {
id
lines(first: 2) {
edges {
node {
id
quantity
merchandise {
... on ProductVariant {
id
title
product {
id
title
}
}
}
}
}
}
}
userErrors {
field
message
}
}
}
Filtering and Sorting
The CartLinesUpdatePayload
itself does not support filtering or sorting directly. However, the nested cart.lines
connection supports pagination and sorting parameters such as first
and after
for pagination.
Example of paginating cart lines after update:
mutation {
cartLinesUpdate(cartId: "eyJhbGciOiJIUzI1NiJ9...", lines: [{id: 67890, quantity: 4}]) {
cart {
id
lines(first: 5, after: "cursor123") {
edges {
cursor
node {
id
quantity
}
}
pageInfo {
hasNextPage
endCursor
}
}
}
userErrors {
message
}
}
}
Implements
This type does not implement any interfaces.
Connections
- The
cart
field connects to theCart
object type, which includes connections such aslines
representing the individual items in the cart. - The
userErrors
field is a list ofUserError
objects, which provide detailed error information related to the mutation.
Related Types
- Cart: Represents the shopping cart and its current state.
- UserError: Represents errors that occurred during mutation operations, including fields and messages describing the error.
Best Practices
- Always check the
userErrors
array after performing acartLinesUpdate
mutation to handle any issues gracefully. - Use pagination parameters on the
cart.lines
connection to efficiently retrieve cart line items, especially for carts with many items. - When updating multiple lines, batch your updates in a single mutation to reduce network overhead.
- Handle errors by inspecting the
field
andmessage
inuserErrors
to provide user-friendly feedback.
Notes
- The API currently requires no authentication; however, this may change in future versions. Plan your integration accordingly.
- The
cart
field in the payload reflects the state of the cart immediately after the update mutation, ensuring you have the latest data. - To optimize performance, request only the fields you need from the
cart
and its nested objects. - The
userErrors
array will be empty if the mutation completes successfully without errors. - No computed or derived fields are present in this type.
- No field arguments are defined on the fields of this type itself; arguments apply to the mutation and nested connections.
Last updated on