GraphQL get product variant quantity

GraphQL get product variant quantity

Shopify Partner
3 0 0

Hi guys,


if anyone knows how to get a quantity of product variant using GraphQL? 


As the documentation says "inventoryQuantity" field should exist in ProductVariant object.


However, when I try to get it I see this error

"No field of name "inventoryQuantity" found on type "ProductVariant" in schema"


My product type is "event" and I do see an "available" field in my ProductVariant which is true. Could it be something wrong in how I set up my Shopify product?


Thx for your help.

Replies 6 (6)

Shopify Partner
1873 184 901

A little more context would be required to understand your error. Are you making direct calls to the API or via a wrapper library / SDK? Are you using the correct endpoint? Storefront API and GraphQL Admin API are considerably different even though many resource object names are the same. It's easy to tell: Storefront is a URL like while GraphQL Admin API is


For instance, the Storefront API only has availableForSale of type boolean. Admin API does in fact have the inventoryQuantity so a admin query such as below would work perfectly fine.


  product(id: "gid:\/\/shopify\/Product\/<PRODUCT_ID>") {
    variants(first: 100) {
      edges {
        node {

Hope this helps!

Shopify Partner
3 0 0

Thx for your reply!


I'm using and requests to Storefront.


This is my current request to get product information.


 let query = client.query((root) => {
      root.add('node', { args: { id: _id }, alias: 'product' }, (node) => {
        node.addInlineFragmentOn('Product', (Product) => {
          Product.addConnection('images', { args: { first: 250 } }, (images) => {
          Product.addConnection('variants', { args: { first: 250 } }, (variants) => {
            variants.add('image', (image) => {

So, you are saying that it's not possible to get variants quantity using Storefront, right? And I should use  GraphQL Admin API, right?

Shopify Partner
1873 184 901

Yes and no 😉


Yes, I am saying you cannot get inventory levels via Storefront API.


No, not necessarily saying you should be using the admin API. That depends on what you are developing. If it is a store, I'd be very careful how you use the admin API. Unlike the Storefront APIs public access token, the admin API requires a key and password which you never want to expose publicly - that would be like giving away your admin UI access credentials.


Second, even if you used the admin API on a server, say a node.js express app or similar, the admin API is throttled and not designed for the kind of load demanded by a store - you'd need to account for this in your design.


Third, if you really need inventory levels you can also work with Liquid - the variant object in Liquid does have an inventory_quantity and you could use a nolayout template to output a JSON object thereby creating your own "kinda API endpoints". However, even the Liquid inventory_quantity is an aggregate of all inventory locations so you wouldn't be able to query how much at location 1, how much at location 2 etc.


If you need inventory level per location then there is no way around admin API, but it will be very difficult to get consistent levels because you will most likely not be able to query the admin API for every storefront request for inventory levels. You'd hit throttling soon. So expect to have cached inventory levels that may be outdated.


Best of luck!

Shopify Partner
235 6 55

Hi There,


My app let's you display inventory information per location on the product detail page in the frontend, is that what you are looking for?


You can check it out here:



Software Developer | Owner of Tom IT - We build shopify apps
Marketplace Order Connector | Amazon & Walmart DSV
Order Related Documents | Print documents, Email document &Autoprint
Blog Product Spotlight | Add products to your blog articles!

1 0 1

Hello Karl, On a similar issue,

I use the Storefront API [end point api/2019-07/graphql.json]

I'm able to query my products in different ways, also using productByHandle, but for some reason i'm not able to use productVariants query like for example:

productVariants(first:1, query: "sku:BMY722"). I get an error that its not exists under QueryRoot.


Any idea what could be the probable reason for this ?

Thank you


11 0 6

Also interested in hearing that 🙂