'Shopify GraphQL: How to know when there is not available product variant image
I need to know with my GraphQL query request when one of the product variants doesn't have the relative image. I have tried to figure it out how to do that but when there is no variant image the image url fallback to the default product image. (Image associated with the product variant. This field falls back to the product image if no image is available.).
https://shopify.dev/api/storefront/2022-04/objects/ProductVariant#fields
query ($productHandle: String!) {
product(handle: $productHandle) {
title
vendor
description
handle
availableForSale
images(first: 50) {
edges {
node {
id
url(transform: { maxWidth: 1100 })
}
}
}
priceRange {
maxVariantPrice {
amount
}
}
variants(first: 100) {
edges {
node {
compareAtPriceV2 {
amount
}
title
id
sku
quantityAvailable
image {
id
url // this url fallback to the default url when there is no image
ico: url(transform: { maxWidth: 100 })
__typename
altText
}
}
}
}
}
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
