I need to filter all products with no SKU set. Using -sku:* isn’t working properly and fails to return some products that have variants with a null SKU.
Running the following queries produces no results:
x-request-id: 271998b6-518d-4df8-b292-881578105614-1783992234
{
products(query:"-sku:*", first:10) {
nodes {
id
title
variants(first:10) {
nodes {
id
title
inventoryItem {
sku
}
}
}
}
}
}
x-request-id: a69bd0f9-f226-4b8a-80bf-304124347f35-1783992200
query {
productsCount(query: "-sku:*") {
count
precision
}
}
x-request-id: 47972fe5-0bb3-42d7-a670-c5807d118955-1783992282
{
productVariants(query:"-sku:*", first:10) {
nodes {
id
title
inventoryItem {
sku
}
}
}
}
Even though the following product ID is one example with variants that have a null SKU:
{
product(id:"gid://shopify/Product/15851419369804") {
id
variants(first:10) {
nodes {
id
inventoryItem {
sku
}
}
}
}
}
Returns the result:
{
"data": {
"product": {
"id": "gid://shopify/Product/15851419369804",
"variants": {
"nodes": [
{
"id": "gid://shopify/ProductVariant/57921697186124",
"inventoryItem": {
"sku": "[redacted]"
}
},
{
"id": "gid://shopify/ProductVariant/57921697153356",
"inventoryItem": {
"sku": "[redacted]"
}
},
{
"id": "gid://shopify/ProductVariant/57922056356172",
"inventoryItem": {
"sku": null
}
},
{
"id": "gid://shopify/ProductVariant/57922056388940",
"inventoryItem": {
"sku": null
}
}
]
}
}
}
}