Storefront API: Cart Retrieve Endpoint Not Returning Line Items

Topic summary

A developer is encountering an issue where the Shopify Storefront API’s cart retrieval endpoint returns an empty lines array despite items being successfully added to the cart.

Query Details:

  • Using a comprehensive GraphQL query to fetch cart data including line items, costs, and buyer identity
  • Requesting first 10 line items with product variant details and attributes
  • Cart ID has been verified as correct

Problem:

  • Response shows edges: [] with no line items
  • hasNextPage: false indicates no pagination issues
  • Items were confirmed to be added successfully to the cart

Potential Causes Being Considered:

  • API permission or scope configuration issues
  • Missing query parameters or incorrect query structure

The issue remains unresolved with the developer seeking input from others who may have experienced similar problems.

Summarized with AI on October 28. AI used: claude-sonnet-4-5-20250929.

Hi everyone,

I’m using the Shopify Storefront API to retrieve a cart by its ID, but the response doesn’t include the line items. Here’s the query I’m using:

query {
  cart(
    id: "gid://shopify/Cart/Z2NwLXVzLWV4YW1wbGU6MDEyMzQ1Njc4OTAxMjM0NTY3ODkw?key=examplekey1234567890"
  ) {
    id
    createdAt
    updatedAt
    lines(first: 10) {
      edges {
        node {
          id
          quantity
          merchandise {
            ... on ProductVariant {
              id
            }
          }
          attributes {
            key
            value
          }
        }
      }
    }
    attributes {
      key
      value
    }
    cost {
      totalAmount {
        amount
        currencyCode
      }
      subtotalAmount {
        amount
        currencyCode
      }
      totalTaxAmount {
        amount
        currencyCode
      }
      totalDutyAmount {
        amount
        currencyCode
      }
    }
    buyerIdentity {
      email
      phone
      customer {
        id
      }
      countryCode
      deliveryAddressPreferences {
        ... on MailingAddress {
          address1
          address2
          city
          provinceCode
          countryCodeV2
          zip
        }
      }
      preferences {
        delivery {
          deliveryMethod
        }
      }
    }
  }
}

Response. :

{
"lines": {
    "pageInfo": {
            "endCursor": null,
            "hasNextPage": false
               },
         "edges": []
}
}

Even though I’ve added items to the cart, the lines array is empty or missing. I’ve verified that the cart ID is correct and that the items were added successfully.

Has anyone else faced this issue? Could this be a permission or scope problem, or am I missing something in the query?