Why can't I access Cart ID with Storefront API via GraphQL?

Topic summary

A developer is encountering issues retrieving cart/checkout data using Shopify’s Storefront API via GraphQL in a custom private app.

Technical Setup:

  • Using Node.js/Express with the Storefront API
  • Receiving checkout ID from a webhook (e.g., 28189070255243005)
  • Encoding the ID as a base64 Global ID: gid://shopify/Checkout/{id}
  • Querying with proper authentication headers (X-Shopify-Storefront-Access-Token)

The Problem:

  • The GraphQL query returns {"node": null} despite receiving a valid checkout ID from the webhook
  • The encoded checkout ID appears correctly formatted
  • Server runs successfully on port 3001, but the node query fails to retrieve checkout data

Current Status:
The issue remains unresolved. The developer has shared their complete code implementation including the webhook handler, GraphQL query structure, and console output showing the null response. They are seeking assistance to understand why the Storefront API cannot access the checkout/cart using the provided ID.

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

Hi, I’m having trouble accessing cart ID with Storefront API. This is with a custom private app I need to develop for a client.

const express = require('express');
const cors = require('cors');
const axios = require('axios');
require('dotenv').config();

const app = express();

app.use(cors());
app.use(express.json());

app.post('/checkout-update', async (req, res) => {
  try {
    const checkout = req.body;
    
    console.log('THIS IS THE CHECKOUT ID:', checkout.id); 
    const encodedCheckoutId = Buffer.from(`gid://shopify/Checkout/${checkout.id}`).toString('base64');
    console.log('Encoded Checkout ID:', encodedCheckoutId);

    const graphqlEndpoint = `https://${process.env.SHOP_NAME}.myshopify.com/api/2023-07/graphql.json`;
    const headers = {
      'X-Shopify-Storefront-Access-Token': process.env.STOREFRONT_ACCESS_TOKEN,
      'Content-Type': 'application/json'
    };

    const checkoutQuery = `
      query getCheckout($checkoutId: ID!) {
        node(id: $checkoutId) {
          ... on Checkout {
            id
            webUrl
            lineItems(first: 5) {
              edges {
                node {
                  title
                  quantity
                }
              }
            }
          }
        }
      }
    `;

    const variables = {
      checkoutId: encodedCheckoutId
    };

    const response = await axios.post(graphqlEndpoint, { query: checkoutQuery, variables }, { headers });

    if (response.data && response.data.data) {
      console.log('GraphQL Response:', JSON.stringify(response.data.data, null, 2));
    } else {
      console.log('Unexpected GraphQL response:', JSON.stringify(response.data, null, 2));
    }
  } catch (error) {
    console.error('Internal Server Error:', error);
  }

  res.status(200).send('GraphQL Test Completed');
});

const port = process.env.PORT || 3001;
app.listen(port, () => {
  console.log(`Server running on port ${port}`);
});

Give me this response:

0|index  | Server running on port 3003
0|index  | THIS IS THE CHECKOUT ID: 981820079255243500
0|index  | This is the encoded id: Z2lkOi8vc2hvcGlmeS9DaGVja291dC85ODE4MjAwNzkyNTUyNDM1MDA=
0|index  | Encoded Checkout ID: Z2lkOi8vc2hvcGlmeS9DaGVja291dC85ODE4MjAwNzkyNTUyNDM1MDA=
0|index  | GraphQL Response: {
0|index  |   "node": null
0|index  | }

As you can see I get checkout ID from the webhook but get a null response in my query. Any help would be greatly appreciated.