GraphQL query filter not working

Solved
maartenvdh
New Member
2 0 1

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

Accepted Solution (1)

Accepted Solutions
L_J_K
Shopify Staff
367 54 65

This is an accepted solution.

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!

 

| API Support @ Shopify |
- Was my reply helpful? Click Like to let me know!
- Was your question answered? Mark it as an Accepted Solution!

View solution in original post

Replies 2 (2)
L_J_K
Shopify Staff
367 54 65

This is an accepted solution.

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!

 

| API Support @ Shopify |
- Was my reply helpful? Click Like to let me know!
- Was your question answered? Mark it as an Accepted Solution!

View solution in original post

maartenvdh
New Member
2 0 1

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