Cart ID not available in Cart and Checkout Validation API GraphQL

Cart ID not available in Cart and Checkout Validation API GraphQL

orange-tango
Shopify Partner
1 0 0

Using the Cart and Checkout Validation API, I am attempting to access a unique property from the checkout session to use as part of the user's validation. The logical piece of data to use for this, that the user cannot alter via cart or line attributes, is the cart ID. On the frontend, the ID I would expect to find looks something like `

gid://shopify/Cart/Z2NwLXVzLWVhc3QxOjAxSFFSUUNYU0ZTR0VaVDBOWVJBNEJQSSvZ`

 

But `id` is not a valid field in the Functions Cart GraphQL object. Attempting to read it as a cart attribute returns null.

 
query RunInput {
  cart {
    lines {
      quantity
      signatureFromBackend: attribute(key: "_backend-signature") {
        value
      }
    }
    id: attribute(key: "id") {
      value
    }
  }
}
 
How can I read the cart ID from my Shopify function? Do I need to hook into the storefront API perhaps?
Replies 0 (0)