Query for only variants with truthy SKUs

Topic summary

A user is attempting to filter a GraphQL productVariants query to return only variants with non-empty SKU values. Currently using the wildcard query sku:*, but this still returns variants with empty string SKUs.

Current Issue:

  • The wildcard approach (sku:*) doesn’t exclude empty strings
  • Many variants are being returned with blank SKU fields

Solution Provided:

  • Modify the query string to sku:-"" to exclude empty SKUs
  • This uses the negation operator (-) to filter out variants where SKU equals an empty string
  • Reference provided to Shopify’s search syntax documentation

Additional Clarification:

  • Empty string appears to be the default SKU value for newly created variants
  • Screenshots were shared demonstrating the query results
Summarized with AI on November 9. AI used: claude-sonnet-4-5-20250929.

Hi, is it possible to constrain a product variants query to just those with a truthy value for SKU?

At the moment I’m passing a wildcard (“queryString”: “sku:*”). But I get quite a few variants with empty strings as the SKU.

I’d also be curious if empty string is the default value for new variants?

Thank you!

`
query($numResults:Int!, $cursor:String, $queryString: String)
{
  productVariants(first: $numResults, after: $cursor, query: $queryString) {
    nodes{
      sku
      title
      inventoryQuantity
      inventoryItem{
        inventoryLevels(first: 5){
          nodes{
            quantities(names:"available") {
              quantity
            }
            location{
              name
              id
            }
          }
        }
      }
    }
    pageInfo{
      hasPreviousPage
      hasNextPage
      startCursor
      endCursor
    }
  }
}
`

Hi, there

You could refer to this https://shopify.dev/docs/api/usage/search-syntax

For your question I’d also be curious if empty string is the default value for new variants? I think empty is the default value.

you could modify you query value to this: “queryString”: “-sku:""”

See the result pic below;