Liquid Weekly's Shopify Inventory Management (GraphQL) Cheat Sheet

By Karl Meisterheim

Shopify Inventory Management with GraphQL — Cheat Sheet

Born from the fires of personal frustration and a real live bug impacting an app I, Karl, present to you the correct, modern way to work with Shopify inventory using GraphQL (as best as I can determine).

1. The Golden Rule

Inventory never lives on the variant. It lives on:

ProductVariant → InventoryItem → InventoryLevels

2. Check If Inventory Is Tracked

productVariant(id: $id) {
  inventoryItem { tracked }
}

tracked: true → inventory counts matter
tracked: false → digital items, gift cards, services

3. Get Real Salable Quantity (Correct Method)

query VariantInventory($id: ID!) {
  productVariant(id: $id) {
    inventoryPolicy
    inventoryItem {
      tracked
      inventoryLevels(first: 50) {
        edges {
          node {
            available
            location { id name isActive }
          }
        }
      }
    }
  }
}

Salable quantity formula:

IF inventoryPolicy == "continue"
    → salable = Infinity (oversell allowed)
ELSE IF tracked == false
    → salable = 0
ELSE
    → salable = SUM(available at active, sellable locations)

4. What “Available” Actually Means

available already accounts for:

  • on_hand
  • reserved
  • committed to fulfillments
  • incoming

It is the exact number Shopify uses to determine if checkout can sell the item.

5. Fields You Can Trust

  • inventoryPolicy
  • inventoryItem.tracked
  • inventoryLevels.available

Never trust (deprecated or misleading):

  • inventory_quantity
  • old_inventory_quantity
  • inventory_management
  • fulfillment_service

6. Minimal Query

query Salable($id: ID!) {
  productVariant(id: $id) {
    inventoryPolicy
    inventoryItem {
      tracked
      inventoryLevels(first: 25) {
        edges { node { available location { isActive } } }
      }
    }
  }
}

7. Minimal Logic

if inventoryPolicy == "continue"
   salable = Infinity
else if not tracked
   salable = 0
else
   salable = sum(available)

Created for discerning developers who want the accurate, modern way to work with Shopify inventory using GraphQL.

ANTI-AI SLOP NOTICE - I utilizd AI tools as appropriate to help author this document but there was always a human in the loop