searchgraphqlshopifyshopify-apishopify-storefront-api

Shopify Storefron API - Search query containing term not working


so what i want to do is querying the products title with a search term and i expect to get all products containing the term somewhere in the title to be returned.

For example in the graphql explorer we have this product title: "3/4 SLEEVE CREWNECK PULLOVER"

I want this to be returned with the following query:

{
  products(first: 250, query:"title:neck") {
    edges {
      node {
        title
      }
    }
  }
}

From the docs i can't figure out a way. If you want to try it out you can do it here: https://shopify.dev/custom-storefronts/tools/graphiql-storefront-api

Any help is appreciated!

Cheers


Solution

  • Writing the query like that will match only product with the same exact title. To search any title containing the string add *:

    {
      products(first: 250, query:"title:neck*") {
        edges {
          node {
            title
          }
        }
      }
    }