Skip to Content

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

FieldTypeNullabilityDescriptionRelationship
cartCartNon-nullableThe updated cart after the lines updateReferences the Cart object
userErrors[UserError]Non-nullableList of errors that occurred during cart lines updateList 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 the Cart object type, which includes connections such as lines representing the individual items in the cart.
  • The userErrors field is a list of UserError objects, which provide detailed error information related to the mutation.
  • 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 a cartLinesUpdate 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 and message in userErrors 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