GraphQL barcode and sku search is not returning results for certain variants

I’m using the following GraphQL queries to retrieve variants via barcode or sku. The queries work for the majority of the inventory but there are some variants that return 0 results despite having available inventory within Shopify at multiple locations. I am currently using GraphQL version 2022-10 and have even upgraded to 2023-04 and I still get no results.

FWIW, when I search for the variants in Shopify using barcode or sku, it works fine.

Here are the queries below:

Barcode Query:

$query = <<<'JSON'
                query($barcode:String,$location:ID!)
                {
                    productVariants(first: 1, query: $barcode) {
                        edges{
                            node{
                                id
                                product{
                                    id
                                    tags
                                    title
                                    featuredImage{
                                        id
                                        url                            
                                    }
                                }
                                displayName
                                title
                                price
                                sku
                                barcode
                                inventoryQuantity
                                position
                                availableForSale
                                taxable
                                image{
                                    id
                                    url
                                    altText
                                    width
                                    height
                                }
                                inventoryItem{
                                    id
                                    sku
                                    unitCost{
                                        amount
                                    }
                                    inventoryLevel(locationId:$location){
                                        available
                                        location{
                                            id
                                        }
                                    }
                                }
                                createdAt
                                updatedAt
                            }
                        }
                    }
                }
            JSON
            ;
            
            $postData = array();
            $postData['query'] = $query;
            $postData['variables'] = array ('barcode'=>$barcode.'*','location'=>$location);

SKU Query:

$query = <<<'JSON'
                query($sku:String,$location:ID!)
                {
                    productVariants(first: 25, query: $sku) {
                        edges{
                            node{
                                id
                                product{
                                    id
                                    tags
                                    title
                                    featuredImage {
                                        id
                                        url
                                        altText
                                    }
                                }
                                displayName
                                title
                                price
                                sku
                                barcode
                                inventoryQuantity
                                position
                                availableForSale
                                taxable
                                image{
                                    id
                                    url
                                    altText
                                    width
                                    height
                                }
                                inventoryItem{
                                    id
                                    sku
                                    unitCost{
                                        amount
                                    }
                                    inventoryLevel(locationId:$location){
                                        available
                                        location{
                                            id
                                        }
                                    }
                                }
                                createdAt
                                updatedAt
                            }
                        }
                    }
                }
            JSON
            ;
            
            $postData = array();
            $postData['query'] = $query;
            $postData['variables'] = array ('sku'=>$sku.'*','location'=>$location);
3 Likes

I’m having very similar issue, and looks like it started yesterday! In my case, product is returned if I search by SKU, but it doesn’t work if I use barcode.

Did you by chance resolve it already?

Thanks for the reply.

Unfortunately, I haven’t resolved the issue yet.

Hi,

We have also noticed that recently (last day we had a few reported issues related to this) productVariants is not able to find some variants. In our case we couldn’t find them using sku, id nor title.

2 Likes

I have experienced this issue as well!

1 Like

Yep this is a recent issue our app has experienced.

1 Like

Similar issue has already been reported. Seems to be affecting the ProductVariants graphql query only. At least we all seem to be having problems with this query.

Got a couple public apps and a bunch of private apps where i use this query to synchronize products assigned to a location in a database. On Monday morning at 2am gmt+1 the query started returning about 1/3 of the results from the day before.. needless to say I’m still trying to put out the fires.

Cheers,

Gary

1 Like

Hey @mahicks11 ! Thanks for letting us know about this. This issue has been resolved so the barcode query will be working now. If you notice it still occurring, reach out to our support team with specific details including your app, store, timeframe and any other specific details that will help us look further!

  • Kyle G.
1 Like

Hey @Kyle ,

Thanks to you and support staff for fixing the issue. I can confirm that the barcode and sku queries are working again.

I’m also having this issue with the ProductVariants query! The weird thing for me is that sometimes the query seems to work in the GraphQL explorer app, but not for my GraphQL Client.

hsdonkin_0-1692373548951.png

@ShopifyDevSup