A space to discuss GraphQL queries, mutations, troubleshooting, throttling, and best practices.
I am unable to get products from the Graph API that match:
Example 1:
products(first: 25, query: "tag:*")...
Will return products that DO NOT have tags.
Example 2:
products(first: 25, query: "-tag:''")...
Will return products that DO NOT have tags.
Example: 3:
products(first: 25, query: "tag:")...
Works almost perfectly. Returns the only two products that have tags and one random product that doesn't have tags. See below:
From the Search documentation: https://help.shopify.com/en/api/getting-started/search-syntax
Exists query
The exists query will match documents with a non-NULL value in the specified field.
query=published_at:*
This query can be combined with a Not Query to find fields missing a value, e.g. -published_at:*
Not sure if there's another way to accomplish this...
Hi @DanAtBonify,
I had success using this query.
{ products(first: 25, query:"tag:*"){ edges{ node{ id tags } } } }
It looks like you already tried this query, but had different results. If possible, can you share a product id with no tags that shows up when doing this query so I can investigate?
Cheers
To learn more visit the Shopify Help Center or the Community Blog.
Hello,
Here are some product IDs that do not have tags that comes back with that result: 4344309251, 4344309443, 4344310275
Thanks for the extra info. I see what you mean. I was also able to replicate on my shop.
I imagine the query I shared is returning products with no tags as they are stored as a blank string, rather than a null value. In any case, I've brought this up as an issue to our engineering team, as I can't find a way to query all products with at least one tag. I'll drop another reply here once I have an update on that issue.
To learn more visit the Shopify Help Center or the Community Blog.
Any update on this? Recently came across this issue as well and basically have no way to highlight a product with 1 or more tags as it ends up showing products with no tags:
while null query works fine:
Hello guys,
how can I search for all the products without any tag (tag is null)?
I am familiar with SQL commands (is null) but here the story seems to be different.
Any kind of support is truly appreciated.
Thank you
Claude
Anyone has a solution for this one ?