Skip to main content

Read a cart line's viewKey from the CartLine type

The CartLine type now exposes a viewKey field, so you can correlate a returned cart line with the viewKey you sent to cartLinesUpdate and cartLinesRemove.

What's new

  • CartLine.viewKey returns the same viewKey your Liquid storefront renders, alongside the existing UUID id.

How to use

Previously, identifying a line by viewKey was input-only: you could send a viewKey, but the response returned a UUID id with no viewKey to map back. You can now read it directly off the line.

query CartLines($cartId: ID!) {
cart(id: $cartId) {
lines(first: 10) {
edges {
node {
id
viewKey
}
}
}
}
}

The field reads a value the cart already stores, so existing UUID-based correlation keeps working unchanged.

Was this section helpful?