GraphQL empty barcode query not working

fb_123
New Member
3 0 0

Hello, I'm using this GraphQL query (v.2021-01) to find variants without barcodes.

However, it's not finding any variants, even though I know and have triple checked that about 10 variants in my account don't have any barcodes assigned.

The weird thing is this kind of search was working just a day ago. So I don't know if there are some stale caches or indexing issues in Shopify. Can anyone help clarify what this issue is?  

{ productVariants(first:250, query:"barcode:'' OR -barcode:*") {
        edges {
          node {
            title
         }
      }
   } 
}

Thanks!

0 Likes
Kevin_A
Shopify Staff
Shopify Staff
311 42 54

Hey @fb_123 

Just tried this and it returned a bunch of variants with null barcodes on my test shop. Is this not what you are seeing?

Kevin_A | Developer Support @ 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

0 Likes
fb_123
New Member
3 0 0

Hey @Kevin_A, thanks for the reply.

I've been doing more tests and narrowed down a bit. It's kinda strange:

a) Say I start with 10 items with no barcode. That query returns those 10 items, as expected.

b) Add barcodes to 5 of those items. The query returns the other 5, as expected.

c) Add barcodes to all the remaining items. And the query returns an empty array. So far, so good.

 

d) However, if I delete the barcode from a few items. ....the query keeps returning an empty array. That's the issue. And if I add new items with no barcode. Query still returns empty.

 

Please try to give all your products a barcode. Then, remove it from a few of them, and run the query. Let me know if that works for you. I've tested with 2 separate accounts and got the same issue.

Thanks again  

0 Likes
fb_123
New Member
3 0 0

I'm attaching the result I get, just to clarify. I've made sure that barcode field is indeed empty. No spaces or any other characters in it.

example.png

0 Likes