skip to Main Content

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?

2

Answers


  1. 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

    Login or Signup to reply.
  2. Also you can try with

    query: "title:*${searchText}*"

    you can see two * at the initial and the end

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search