How do I query the cart line properties attribute?

Topic summary

Issue: A developer struggled to query custom data from the properties attribute on cart lines using GraphQL in Shopify Functions.

Initial Problem:

  • Standard attribute queries weren’t returning the properties field
  • The user needed to access custom data added when products are added to cart

Solution Found:
Custom properties must be queried using a specific key prefix:

attribute(key: "_custom_data")

Key Technical Constraints:

  • Shopify Functions APIs differ from Storefront API—they cannot query unbounded lists for performance reasons
  • Each attribute must be queried individually by specifying its exact key
  • Inline fragments (available in Storefront API) don’t work in Functions context

Ongoing Challenge:
For expanded products with variable/dynamic property names, developers face limitations:

  • All original properties from expanded items don’t automatically carry through to order notes
  • Workaround suggested: stringify all key/value pairs into a single hidden custom attribute, then parse it in cart transform code
  • ExpandedItem attributes are available in API version 2024-04+

Status: Partial resolution—basic querying works, but handling dynamic properties across varied products remains complex.

Summarized with AI on November 7. AI used: claude-sonnet-4-5-20250929.

I managed to figure it out. Data added to the properties attribute are considered to be custom properties, so one just has to target the key of that custom property.

query RunInput {
  cart {
    lines {
      id
      quantity
      custom_data: attribute(key: "_custom_data") {
        value
      }
    }
  }
2 Likes