GraphQL -> get products that does not contain metafield

tomkwa
New Member
1 0 0

Hi all,

thats my first post in this community, so be a bit forgiving

Well... I have a shop with clothes. Each cloth product has a size chart which I store in json_string metafield.
Everything is working just fine but... I can query by graphQL for products with this key:'size_chart' metafield. 
But... how to query for products that doesnt have this metafield (or size_chart metafield is null )?

Any ideas?

0 Likes
HunkyBill
Shopify Expert
4509 46 492

When you query for a product that has the Metafield, the node returned will exist. So you know you have a size chart. When you use the exact same query to get a product that does not have the Metafield, the node will be null or nil for it. So you need not alter anything and you get both. So just alter your processing logic to look for the null or nil on that field and do as you need to do.

In other words, while you may get products that DO have it, you also get products that do not. And there is no query as far as I know that would be "all products but not with that Metafield". Seems counter-intuitive... but that is that. I could be wrong. Maybe you can put a NOT condition in the query but that would not make sense...

Custom Shopify Apps built just for you! hunkybill@gmail.com http://www.resistorsoftware.com
0 Likes