Hello guys, I'm wondering what's the syntax we should use for the "query" argument many of the Objects offer. The documentarion say "String" and passing for example "Accessories" to find Products in the "Accessories" collection works. But it feels a little loose. Is there a way to make it more explicit that I'm only searching for collections called "Accessories"?
This was just an example, any information on the topic will contribute a lot! Thanks!
Thanks for replying! That's a confusing feature because it only seems to work in some cases. For example, if I do:
products(first: 10, query: "title='Verma'")
It works, but if I do:
products(first: 10, query: "product_type='Men'")
It does not work even though the documentation says "product_type" is supported as a filter in the query argument.
Do you see anything I might be doing wrong here?
Just got a reply from a staff at Shopify and from his response and my tests I understood that you can do things like:
products(first:10, query:"product_type:'Men' title:'My product'")
There has to be no space between the colon and the value queried, and there is no comma between parameters. Also, it's case insensitive.
So, this is a bit of a mess. And believe it or not, this thread is currently the best documentation on how to use the query field.
@Shopify, please help us out here as we're currently doing guesswork.
Here's what I know so far:
While you can see what query fields are claimed to be supported here (https://help.shopify.com/en/api/graphql-admin-api/reference/queryroot) it is actually not accurate. Only some of those fields are in practice supported. But, some actually do work.
I'm currently working on orders() and for this it seems that the status of the working/non-working query fields are:
- email: not working
- status: not working?
- fulfillment_status: IS WORKING
- customer_id: IS WORKING
When running queries, the correct format is this:
The incorrect format is this (incorrectly claimed to be correct in a previous post):
(e.g. do not use '=' but instead ':'
It seems that the query field is insensitive to extra quotations for at least numbers. The following does work:
It is also insensitive to left out quotations for strings.
I hope this helps someone out there trying to get this working despite of Shopify's complete lack of documentation and support for the community.