Warm tip: This article is reproduced from serverfault.com, please click

Shopify Storefront API 2020-10 (latest) can't fetch quantityAvailable (GraphQL)

发布于 2020-12-05 18:57:15

For the first time I'm working with Shopify Storefront API (v. 2020-10, latest) and trying out GraphQL (I'm used to REST).

I'm able to get all the products, but if I add the field "quantityAvailable" an error occur:

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

I'm following the docs where the field is listed, can you help me understand what am I doing wrong?

GraphQL Query

Edit #1 I've already enabled "Read inventory of products and their variants" in Storefront API Permissions.

Edit #2 I'm sending a POST request to https://{my-shopify-website}/api/graphql attaching content-type and X-Shopify-Storefront-Access-Token as header

Questioner
LLuca
Viewed
0
drip 2020-12-06 19:17:56

Using the /api/2020-10/graphql end-point allows the usage of quantityAvailable property, but using the unstable end-point /api/graphql doesn't.

This seems more like a Shopify docs or API bug/issue, but the solution is to use the specific version end-point (/api/2020-10/graphql) instead of the unstable one.