Dedicated to the Hydrogen framework, headless commerce, and building custom storefronts using the Storefront API.
I can easily find the pricerange and some other product informations with this query :
const params = {
query : `query {
products(first: 250, query: "` + query + `") {
edges {
node {
id
title
handle
onlineStoreUrl
tags
priceRange {
maxVariantPrice {
amount
currencyCode
}
minVariantPrice {
amount
currencyCode
}
}
images (first:1) {
edges {
node {
originalSrc
altText
}
}
}
}
}
}
}`
};
But if I add the compareAtPriceRange according to the documentation like this :
const params = {
query : `query {
products(first: 250, query: "` + query + `") {
edges {
node {
id
title
handle
onlineStoreUrl
tags
priceRange {
maxVariantPrice {
amount
currencyCode
}
minVariantPrice {
amount
currencyCode
}
}
compareAtPriceRange {
maxVariantPrice {
amount
currencyCode
}
minVariantPrice {
amount
currencyCode
}
}
images (first:1) {
edges {
node {
originalSrc
altText
}
}
}
}
}
}
}`
};
I'm getting this error:
Field 'compareAtPriceRange' doesn't exist on type 'Product'
I'm facing a similar issue for few days !
I have the same exact issue! In my mind it should be queried just like priceRange based on docs, and it is listed as a field on the Product object. Would definitely appreciate some insight here @shopify
Just ran into same issue.
It looks like compareAtPriceRange was added in API version 2020-04.
Updating the API version in my graphQl endpoint to 2020-07 fixed this for me.
You can view here how the field is shown when you are in 2020-04 or later version: https://shopify.dev/docs/storefront-api/reference
Just got an email post got a thumbs up, cool thank you!
But there is still an issue here!!!
compareAtPriceRange does not work properly in any current API version ( as far as we tested )
There is an open issue on github that we can confirm and have replicated: https://github.com/Shopify/js-buy-sdk/issues/774
We got around this bug for now by looping over variants using compareAtPriceV2 to get the data we needed. Not ideal since a top level query would be a lot cleaner, but it can work.
Hi everyone -
The bug with the compareAtPriceRange returning the incorrect range is under investigation! The fact that it was not appearing is due to the wrong version as pointed out in earlier comments. I'll update here when this has been updated.
To learn more visit the Shopify Help Center or the Community Blog.
Regrading this URL from shopify 'https://shopify.dev/graphiql/storefront-graphiql' compareAtPriceRange is available in product but when i used i got error
Field 'compareAtPriceRange' doesn't exist on type 'Product'
Field 'totalInventory' doesn't exist on type 'Product'
but both are available in the version (2010-10 latest).
any idea?
@JustinMetros @sullizer @marissatraina We have pushed a change that should accurately reflect the proper compare at price range. Let me know if you see otherwise.
To learn more visit the Shopify Help Center or the Community Blog.