Admin GraphQL query filter not working

Solved
Tolulope_Akinol
Shopify Partner
25 1 1

One of the samples in the product query section of the Admin GraphQL illustrates how you can use the "query" variable to filter product nodes by productType (https://shopify.dev/docs/admin-api/graphql/reference/object/product)

 However, the filter query:"productType:shirt" returns nodes with productType different than "shirt".  I also tried this query in a live shop and had similar results.  Is it possible to filter results with a query on  productType or other fields?

 

Screen Shot 2020-09-24 at 12.22.13 AM.png

Accepted Solution (1)
Kevin_A
Shopify Staff
Shopify Staff
318 42 61

This is an accepted solution.

Hey @Tolulope_Akinol 

You are querying on a field that doesn't exist, hence why the results aren't as expected. If you look at the documentation for the product query root, it specifies you can query on "product_type" not "productType". See here for reference: https://shopify.dev/docs/admin-api/graphql/reference/queryroot

Kevin_A | Solutions Engineer @ 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

Replies 5 (5)
haupham
Visitor
3 0 0

I have the same problem but it is with draftOrders @@

https://community.shopify.com/c/Shopify-APIs-SDKs/draftOrders-first-10-query-quot-email-bob-slydell-...

This is really frustrated though

Kevin_A
Shopify Staff
Shopify Staff
318 42 61

This is an accepted solution.

Hey @Tolulope_Akinol 

You are querying on a field that doesn't exist, hence why the results aren't as expected. If you look at the documentation for the product query root, it specifies you can query on "product_type" not "productType". See here for reference: https://shopify.dev/docs/admin-api/graphql/reference/queryroot

Kevin_A | Solutions Engineer @ 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

Tolulope_Akinol
Shopify Partner
25 1 1

@Kevin_A Thanks for the clarification but the screenshot is directly from the Shopify documentation so I would recommend updating it to remove the wrong field reference

Kevin_A
Shopify Staff
Shopify Staff
318 42 61

Hey @Tolulope_Akinol 

Thanks for the heads up on that! I will look into getting that corrected. 

Kevin_A | Solutions Engineer @ 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

QuanIceTea
Tourist
5 0 1

Hey @ Kevin_A

How can I filter product not have specific product_type (like the way NOT tag or -tag, NOT vendor or -vendor)

QuanIceTea