Ad

Shopify GraphQL Partial Matching On Query Filter

- 1 answer

I'm just getting started with the new Shopify GraphQL Admin API. I'm trying to retreive all products, where the title field contains a certain word.

Currently I can successfully retrieve a product by including the full product title (exact match):

{
  shop {
    id
    name
  }
  products(first: 10, query:"title:'RAVEN DUSTY OLIVE/SILVER MESH'") {
    edges {
      node {
        productType
        title
      }
    }
  }
}

However, I want to partially match the title to display all products with the word "Raven" anywhere in the title, but the following returns no results:

{
  shop {
    id
    name
  }
  products(first: 10, query:"title:'RAVEN'") {
    edges {
      node {
        productType
        title
      }
    }
  }
}

Any ideas on how to get the partial matching working?

Ad

Answer

Bjorn! This should work:

{
  shop {
    id
    name
  }
  products(first: 10, query:"title:RAVEN*") {
    edges {
      node {
        productType
        title
      }
    }
  }
}

Check out the docs: https://help.shopify.com/en/api/getting-started/search-syntax

Ad
source: stackoverflow.com
Ad