Our Partner & Developer boards on the community are moving to a brand new home: the .dev community forums! While you can still access past discussions here, for all your future app and storefront building questions, head over to the new forums.

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

Solved

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

amatosc
Visitor
2 0 0

Hello there,

I'm using Shopify's GraphQL API (Python SDK) to get products, their variants and meta-fields. I've tested my query on Postman and Shopify Admin API GraphiQL explorer and it seems to work just fine but when use python SDK I get the following error: 

{"errors":[{"message":"Field 'contextualPricing' doesn't exist on type 'ProductVariant'","locations":[{"line":27,"column":15}],"path":["query","products","edges","node","variants","edges","node","contextualPricing"],"extensions":{"code":"undefinedField","typeName":"ProductVariant","fieldName":"contextualPricing"}}]}

Here the code snippet:

products_query = """{
  products(first: 5, sortKey: ID) {
    edges {
      cursor
      node {
        id
        handle
        hasOnlyDefaultVariant
        status
        tags
        title
        totalInventory
        vendor
        metafields(first: 5) {
          edges {
            node {
              id
              key
              namespace
              value
            }
          }
        }
        variants(first: 5) {
          edges {
            node {
              contextualPricing(context: {}) {
                price {
                  amount
                }
                compareAtPrice {
                  amount
                }
              }
              sku
            }
          }
        }
      }
    }
  }
}"""

shopify.ShopifyResource.activate_session(shopify_session)
result = shopify.GraphQL().execute(products_query)
shopify.ShopifyResource.clear_session()

 

Any Ideas? 

 

Regards,

Alex.

 

Accepted Solution (1)

tewe
Shopify Partner
245 46 103

This is an accepted solution.

Hi @amatosc ,

I suspect you use an old API version. If  you test it on 2021-10 it works. 

Regards
Thomas 

• Was my reply helpful? Click Like to let me know!
• Was your question answered? Mark it as an Accepted Solution
• Check out our Price Updater App

View solution in original post

Reply 1 (1)

tewe
Shopify Partner
245 46 103

This is an accepted solution.

Hi @amatosc ,

I suspect you use an old API version. If  you test it on 2021-10 it works. 

Regards
Thomas 

• Was my reply helpful? Click Like to let me know!
• Was your question answered? Mark it as an Accepted Solution
• Check out our Price Updater App