How to GraphQL query string match

Solved

How to GraphQL query string match

YR
Visitor
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 

Accepted Solution (1)

vix
Shopify Staff
540 103 122

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. 

To learn more visit the Shopify Help Center or the Community Blog.

View solution in original post

Replies 2 (2)

vix
Shopify Staff
540 103 122

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. 

To learn more visit the Shopify Help Center or the Community Blog.

Bradlplaydon
Tourist
23 0 2

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
  }