GraphQL: Query product by product handle - exact match.

Highlighted
New Member
7 0 0

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.

0 Likes
New Member
7 0 0

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.

0 Likes
Highlighted
Shopify Partner
66 5 26

There is a specific query for this:

query ($handle: String!) {
  productByHandle(handle: $handle) {
    id
    handle
    title
    tags
    productType
    vendor
  }
}