How to GraphQL query string match

Solved
YR
New Member
1 0 0

I'm wondering if graphQL could query exact string match, for example:

query {
   products(first: 50, query: "tag:'product-family:unique family one' tag:'master-product:TRUE'") {
    edges {
      node {
        tags        
      }   
    }
  }
}

There's only one product-family tag for each product. The above query outputs all the right products PLUS products that contain "product-family:unique family one lorem" , which I don’t want.


It seems like the query is doing partial string match rather than exact string match, if that makes sense. 

 

Any idea how to perform exact string match query? 

I've checked out these two links and found nothing:

https://shopify.dev/concepts/graphql/queries 
https://shopify.dev/concepts/about-apis/search-syntax 

0 Likes
vix
Shopify Staff
Shopify Staff
534 105 103

This is an accepted solution.

Hey @YR 

 

There is a good explanation of this you can find here:https://community.shopify.com/c/Shopify-APIs-SDKs/GraphQL-Admin-API-Search-Products-by-Tag/m-p/51244...

 

Unfortunately, in this case tags are partially matched, so additional filtering will be needed or updating the naming conventions. 

Vix | Developer Support @ Shopify 
 - Was my reply helpful? Click Like to let me know! 
 - Was your question answered? Mark it as an Accepted Solution
 - To learn more visit Shopify.dev or the Shopify Web Design and Development Blog

0 Likes
Bradlplaydon
Tourist
23 0 0

I know this is an old post however i'm having the same issue however instead of trying to match based on tag I am trying to match based upon product type so I can create a product alternatives section I capture the product type in JS through the product object then use that as a variable in my GraphQL call however because we have product types which have spaces in them it's not exactly matching the product types I want it's pulling in "Roller Frames" & "Roller Sleeves" all I want is Roller Sleeves 

query: `query ($productType: String!) {
  products(first: 250, query: $productType) {
    edges {
      node {
        id
        handle
        description
        productType
        title
        tags
        options {
          name
          values
        }
        images(first: 10) {
          edges {
            node {
              src
            }
          }
        }
        variants(first: 250) {
          edges {
            node {
              sku
              price
              quantityAvailable
              id
            }
          }
        }
      }
    }
  }
}
`,
  variables: {
      "productType": thisProdType
  }

 

0 Likes