Unable to get the `avaialableQuantity` property in StoreFront API

Solved
Highlighted
New Member
2 0 1

Hello my dev fellows,
Im working on mobile app using StoreFront API and i'm not able to get the avaialableQuantity property for each variant, I found this link https://shopify.dev/changelog/inventory-quantity-available-on-storefront-graphql-api, but there is no thing such as the "inventory quantity" checkbox meanwhile there is a "unauthenticated_read_product_inventory" checkbox. i checked it as mentioned here https://shopify.dev/docs/storefront-api/reference/object/productvariant?api[version]=2020-04. Still no luck same error :

 

Field 'quantityAvailable' doesn't exist on type 'ProductVariant'

Im stuck as the property is very important to decide whether the product is available for certain quantity or not.

Any help would be greatly appreciated

1 Like
Highlighted
Tourist
4 0 2

We have the exact same problem.

It seem to be a bug into the api 😢

 

Did you find a solution?

I think the only workaround is to use Shopify Admin api 😬

0 Likes
Highlighted
Shopify Staff
Shopify Staff
438 90 66

This is an accepted solution.

Hi @JAM-Team @sidaticom 

 

If you are utilizing version 2020-4 and have granted the permission unauthenticated_read_product_inventory access scope

you should have no problem accessing this information from the Storefront API. Here is an example query: 

 

 

query {
  products(first:1)
 {
    edges {
      node {
        variants(first:1) {
          edges {
            node {
              availableForSale
              quantityAvailable
            }
          }
        }
       title
        id
        publishedAt
      }
    }
  }
}

 

 

Vix | Developer Support @ Shopify
 - Was my reply helpful? Click Like to let me know! 
 - Was your question answered? Click Accept as Solution 


1 Like
Highlighted
New Member
2 0 1

Thanks to @vix, i start checking the API version and i found out that i'm using

Instead of

https://store-id.myshopify.com/api/2020-04/graphql 

After fixing that issue, the API is now working as expected, hope this is the case with you too @JAM-Team 

0 Likes
Highlighted
Tourist
4 0 2

Yeah it was the same problem, thanks @sidaticom & @vix 

0 Likes