single query to get everything about the first product

Topic summary

Goal: build a single GraphQL query that returns everything about the first product, including InventoryItem and InventoryLevel (their GIDs), alongside existing data already retrieved (product details, images/media, variants, options, option values). Pagination is working.

Problem: attempts to include inventory/quantity fields trigger errors like “quantity no longer exists” and “quantities requires names.” The request specifically needs InventoryItem.id and InventoryLevel.id.

Latest update: a sample query is provided that fetches a product by ID and includes:

  • Core product fields (title, tags, handle, description, SEO, status, vendor, category, featured image, images, publications count, compareAtPriceRange, totalInventory).
  • Variants with image, price, inventoryPolicy, inventoryQuantity, and nested inventoryItem (id, sku, tracked, unitCost, measurement, etc.).
  • Per-location inventoryLevel via inventoryItem.inventoryLevel(locationId: “gid://shopify/Location/…”) returning id and metadata.
  • Options with optionValues and swatches.

Notes: InventoryLevel requires a locationId (GID = global ID) to return per-location quantities, which may address the quantity-related errors.

Status: proposed solution awaits confirmation; unresolved whether it fully meets the “first product” use case (query expects a product ID).

Summarized with AI on December 22. AI used: gpt-5.

Hi everyone

Bit of a long shot, I have spent weeks on this query

I want to run a single query, this gets the first product.

Now I dont want just the product, i want everything connected to that product and i mean everything.

Currently I can get the first product and with it

product details

image details

media details (video’s etc)

variants

product options inside variants

option values inside the product options

I need to be able to get the InventoryItem and InventoryLevel - these are the missing bits.

Everytime i think i am getting close, i constantly get quantity no longer exists, quantities requires names,

I just want a single query to return everything about the first product

I have the pagenext working, that took some brain power - it shouldnt off.

Any help would be appricated, thanks

I have attached a screen shot of what i am working on, I can get the quanities returned in a round about way but i need to know the inventoryitemid, the inventotylevelid (gid’s)

Many thanks

Dave.

Hi @PremierEPOS

Can the following code meet your needs?

query getProduct ($id: ID!){
  product(id: $id) {
    title
    tags
    handle
    availablePublicationsCount{
        count
        precision
    }
    category {
        id
        name
        level
        isLeaf
    }
    description
    onlineStoreUrl
    compareAtPriceRange{
        maxVariantCompareAtPrice{
            currencyCode
            amount
        }
        minVariantCompareAtPrice{
            currencyCode
            amount
        }
    }
    defaultCursor
    featuredImage{
        altText
        url
    }
    hasOnlyDefaultVariant
    hasOutOfStockVariants
    hasVariantsThatRequiresComponents
    requiresSellingPlan
    isGiftCard
    legacyResourceId
    images(first: 10){
        edges{
            node{
                id
                src
                altText
                
            }
        }
    }
    updatedAt
    variantsCount{
        count
        precision
    }
    variants(first: 10){
        edges{
            node{
                id
                title
                displayName
                price
                compareAtPrice
                image {
                    id
                    url
                }
                inventoryItem {
                    countryCodeOfOrigin
                    id 
                    createdAt
                    duplicateSkuCount
                    harmonizedSystemCode
                    inventoryHistoryUrl
                    inventoryLevel(locationId: "gid://shopify/Location/69855576286"){
                        id
                        canDeactivate
                        createdAt
                        deactivationAlert
                        location{
                            isActive
                        }
                    }
                    locationsCount{
                        count
                        precision
                    }
                    measurement{
                        id
                        weight{
                            unit
                            value
                        }
                    }
                    provinceCodeOfOrigin
                    requiresShipping
                    sku
                    tracked
                    unitCost{
                        amount
                        currencyCode
                    }
                    updatedAt
                }
                inventoryPolicy
                inventoryQuantity
            }
        }
    }
    variantsCount{
        count
        precision
    }
    options(first: 10){
        id
        linkedMetafield{
            key
            namespace
        }
        name
        values
        optionValues {
            id
            linkedMetafieldValue
            name
            hasVariants
            swatch{
                color
                image{
                    fileStatus
                }
            }
            
        }
        position
    }
    totalInventory
    seo{
        title
        description
    }
    status
    tags
    vendor
  }
}