A space to discuss GraphQL queries, mutations, troubleshooting, throttling, and best practices.
I am getting this error message Field 'compareAtPriceRange' doesn't exist on type 'Product' using this endpoint:
/admin/api/2020-10/graphql.json
query {
products(first: 5) {
edges {
node {
title
priceRange { minVariantPrice { amount } }
compareAtPriceRange { minVariantPrice { amount } }
}
}
}
}
If I take out compareAtPriceRange { minVariantPrice { amount } } the query works fine.
What am I doing wrong? Per this documentation this seems correct: https://shopify.dev/docs/storefront-api/reference/products/product#compareatpricerange-2020-10
It seems I may have found the answer which is that compareAtPriceRange is only available on the Storefront API, and not the Admin API. Is that correct?
It also seems that bulk operations are only available on the Admin API, and not the Storefront API. Is this also correct?
Following graphql query works for me to get the compareAtPrice along with price through variants connection.
query {
product(id: <productId>) {
id
title
variants(first: 1) {
edges {
node {
compareAtPrice
price
}
}
}
}
}
Hey @Scuba-js ,
Thanks for sharing those additional details.
The issue here appears to be that the admin API that you're requesting does not have the compareAtPriceRange field. https://shopify.dev/docs/api/admin-graphql/2023-01/objects/ProductVariant
The document you shared is for the storefront API, which has a different endpoint URL (no admin in the URL)
- https://shopify.dev/docs/api/storefront#endpoints
If you're looking to use the storefront API, adjusting the URL should resolve this for you, however if you're looking for this through the admin API, then you'll need to use the compareAtPrice
Hope that helps!
- Kyle G.
Developer Support @ Shopify
- Was this reply helpful? Click Like to let us know!
- Was your question answered? Mark it as an Accepted Solution
- To learn more visit Shopify.dev or the Shopify Web Design and Development Blog