Dedicated to the Hydrogen framework, headless commerce, and building custom storefronts using the Storefront API.
I'm having issues being able to find a way to query by a product handle returning an exact match
The following returns any product that has "vista-pro-60" in any searchable field.
{
products(first: 1, query: "'vista-pro-60'") {
edges {
node {
id
handle
title
tags
productType
vendor
}
}
}
}
According to the graphQL docs on Shopify the product handle is not listed. This seems like a mistake to me. Am I missing something?
I've also tried the following just to be sure they didn't accidentally leave it off the docs:
products(first: 1, query: "handle: 'vista-pro-60'")
Any insight or help would be greatly appreciated.
Found a non graphQL solution. I updated the graphQL to
products(first: 10, query: "'vista-pro-60'")
And then filtered down the response to the node that was an exact match.
There is a specific query for this:
query ($handle: String!) {
productByHandle(handle: $handle) {
id
handle
title
tags
productType
vendor
}
}
productByHandle is deprecated, use this instead:
{
product(handle:"{{handle}}") {
title
}
}