GraphQL query filter not working

I am probably missing something simple but I cannot find what.

When I run this GraphQL query in the Shopify GraphiQL App it comes back with 10 products:

{
  shop {
    name
  }
  products(first: 10) {
    edges {
      node {
        id
        title
        description
      }
    }
  }
}

When I add a query filter like this:

{
  shop {
    name
  }
  products(first: 10, query: "title=bike") {
    edges {
      node {
        id
        title
        description
      }
    }
  }
}

It comes back with nothing :disappointed_face: , but when I run this on https://shopify.dev/apps/tools/graphiql-admin-api it works. Is there maybe some setting in the shop that I am missing that doesn’t allow filtering on title?

Other queries I tried which where not working:

  • products(first: 10, query: “description=the”)
  • products(query:“title:bike” first:5 )
  • products(first: 10, query:“title=b”)

Hopefully someone can shine a light and push me in the right direction.

Hey @maartenvdh

Thanks for getting in touch! So I’d tried this below in GraphiQL with the equality comparator(docs) on my title, which is the way of returning the product title - please see below.

{
  shop {
    name
  }
  products(first: 10, query: "title:mycoolproduct") {
    edges {
      node {
        id
        title
        description
      }
    }
  }
}

I’m returned two results in my store’s GraphiQL app - that’s expected for me as I only have two products on my store that hold the title of ‘mycoolproduct’. There’s some further docs here on comparators here if needed too. Hope that helps!

1 Like

@Luke_K thanks I am not sure what I did wrong but it works now

1 Like