Development discussions around Shopify APIs
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.
Solved! Go to the solution
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
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
Photo by Marco Verch Sales channels on Shopify are various platforms where you can sell...
By Ollie May 25, 2023Summary of EventsBeginning in January of 2023, some merchants reported seeing a large amo...
By Trevor May 15, 2023With 2-Factor Authentication being required to use Shopify Payments, we’re here to help yo...
By Imogen Apr 26, 2023