GraphQL Storefront API now supports narrowing variants by option values
timestamp1572394500001
Storefront API
Enhancement
Using the Storefront API, you can now narrow the collection of variants on a product based on a set of option values. This is similar to how you can refine the product
node response based on option values.
For example, if a shopper selects a “Red” value from a “Color” option, you may want to display information about only the “Red” variants to them, and this allows you to request those explicitly from the API.
Consider this query:
query {
site {
product(entityId: 6606) {
name
entityId
variants(
optionValueIds: [{ optionEntityId: 2403, valueEntityId: 2718 }]
) {
edges {
node {
sku
defaultImage {
url(width: 200)
}
}
}
}
}
}
}