GraphQL Query Filter: How do we determine the filterable fields?

Solved
bashunaimiroy1
Shopify Partner
9 1 5

Hi my wonderful Shopify community. 

 

I'm running into a bit of a problem using the GraphQL Admin API query filtering. I'll start with the more general problem, and then list my specific prooblem.

 

The general problem:

The examples I see of filtering the GraphQL Query keep using field names which aren't documented in the GraphQL Admin API docs as far as I can tell.

 

E.g. this example from the docs uses "inventory_total" to filter products, which isn't documented.

`Product.totalInventory` is, on the other hand, documented. But how would I look at that field and think "hm, I want to filter my products on that field, in my GraphQL Query. I should reverse the order of the words and add an underscore between them." It's not quite intuitive. But perhaps I'm missing some mapping between these two, or some documentation that lists the field names? I thought perhaps it would be the QueryRoot docs, but I can't quite figure out where to look there.


Here's a forum post with the same problem- how did we get from productType, which is listed in the GraphQL  to product_type, which isn't listed anywhere, including the QueryRoot documentation that the answerer linked?

 

Thanks so much folks! This would be a huge help to get answered.

 

My Specific Problem:


I'm trying to filter Orders that have a non-null shipping address, and `

orders(first: 20, query: "shipping_address:*", reverse: true) {` doesn't seem to be working at all, and I'm wondering if my field name is wrong.

Edit to add:
 
It looks like this issue has been around for a while and didn't get great answers then.
 
I know you're probably tired of hearing this, but: the docs are incomplete and are preventing devs from using the no doubt wonderful product you've made. It would be really appreciated if we could get documentation on this. Thanks!
Accepted Solution (1)
bashunaimiroy1
Shopify Partner
9 1 5

This is an accepted solution.

I found a mostly complete answer: the possible query filter values have been listed (though without any possible values) in the "Queries" subitem under each Object in the GraphQL Admin API Docs. e.g. here is every possible query filter value for Order.  

 

Looking through them, I can see that "shipping_address" isn't filterable.

 

I hope this is useful to anybody happening upon this. Granted, it doesn't tell you what these field names map to, or what values are possible, but the first one's hopefully intuitive.

 

View solution in original post

Reply 1 (1)
bashunaimiroy1
Shopify Partner
9 1 5

This is an accepted solution.

I found a mostly complete answer: the possible query filter values have been listed (though without any possible values) in the "Queries" subitem under each Object in the GraphQL Admin API Docs. e.g. here is every possible query filter value for Order.  

 

Looking through them, I can see that "shipping_address" isn't filterable.

 

I hope this is useful to anybody happening upon this. Granted, it doesn't tell you what these field names map to, or what values are possible, but the first one's hopefully intuitive.