How to use ID within a group to filter against products?

Solved

How to use ID within a group to filter against products?

basima25z
Shopify Partner
6 0 0

Hello, when I add ID to a group filter, it fails to return the correct products, for example:

 

query: "((title:navy*) OR (product_type:navy*) OR (id:navy))"

 

 

 

query getProducts {
products(first: 10 query: "((title:navy*) OR (product_type:navy*) OR (id:navy))"){
nodes {
	id
  title
}
}
}

 

 

If I run this query in the Graph QL explorer connected to my store, it fails to return the correct products, it returns an empty nodes []. This only happens when the ID is tacked on, if i remove it, it returns the correct products. However, even with ID being present in the query, since I'm using an OR it should still return the correct products if it matches product_type or title, regardless of if the ID should have a match. 

 

If I put in an ID in the query above, instead of `navy`, it returns the correct product that matches that ID.

 

If I used any other filter argument instead of ID, for example tacking on vendor, it returns the correct products. 

 

I'm not sure if this is a bug, but this only happens with IDs being apart of a group, as i've tested it with other arguments as well.

Just for reference, here is what you can filter against: https://shopify.dev/api/admin-graphql/2022-07/objects/Product#query-products

Accepted Solution (1)

mikerowave
Shopify Staff (Retired)
22 3 2

This is an accepted solution.

Hi @basima25z!

The expected format for an ID field in GraphQL queries is something like "gid://shopify/Product/10079785100". You can read more about this in our docs on Global IDs.

Mike M (mikerowave) | API Support @ Shopify 
 - Was my reply helpful? Click Like to let me know!
 - Was your question answered? Mark it as an Accepted Solution
 - To learn more visit shopify.dev or the Shopify Web Design and Development Blog

View solution in original post

Reply 1 (1)

mikerowave
Shopify Staff (Retired)
22 3 2

This is an accepted solution.

Hi @basima25z!

The expected format for an ID field in GraphQL queries is something like "gid://shopify/Product/10079785100". You can read more about this in our docs on Global IDs.

Mike M (mikerowave) | API Support @ Shopify 
 - Was my reply helpful? Click Like to let me know!
 - Was your question answered? Mark it as an Accepted Solution
 - To learn more visit shopify.dev or the Shopify Web Design and Development Blog