Search for null variant values using graphql and search syntax

Rusty-Dev
Tourist
8 0 4

I'm trying to search for variants missing a taxCode and can't seem to get the query to return the correct results. I'm using the exists query:

 

query {
  productVariants(first:250, query:"-taxCode:*") {
    edges {
      node {
        title
        id
        taxCode
      }
    }
  }
}

Returns:

 

"data": {
  "productVariants": {
    "edges": [
      {
        "node": {
          "title": "Brown \/ Medium",
          "id": "gid:\/\/shopify\/ProductVariant\/13343879364660",
          "taxCode": "PC040129"
        }
      },
      ...
] } }

So obviously not a variant missing a taxCode :)

 

sd_
Shopify Staff (Retired)
Shopify Staff (Retired)
51 10 5

Hi there,

 

TaxCode is not a field that you can filter product variant search results on. If you are looking for product variants that are missing a taxCode, you will have to do so manually. 

 

 

0 Likes
Menaka
New Member
2 0 0

There seems to be some kind of bug. I am not able to query for taxCode now. 

 

Request:


query {
productVariants(first: 100) {
edges {
node {
title
id
taxCode
selectedOptions { name value }
}
}
}
}

 

 

Response:

 

{
"errors": [
{
"message": "Field 'taxCode' doesn't exist on type 'ProductVariant'",
"locations": [
{
"line": 8,
"column": 17
}
],
"path": [
"query",
"productVariants",
"edges",
"node",
"taxCode"
],
"extensions": {
"code": "undefinedField",
"typeName": "ProductVariant",
"fieldName": "taxCode"
}
}
]
}

0 Likes
Jroyce1180
Pathfinder
85 4 14

Surely there must be a workaround to get a result of all Products or ProductVariants that have an empty taxCode. Why not just take the results of the following query into an array and then loop through to find all the products without a taxCode. Wouldn't that work? 

{
    products(first: 50) {
      pageInfo {
        hasNextPage
        hasPreviousPage
      }
      edges {
        node {
          id
          title
          variants (first: 1) {
            edges {
              node {
                taxCode
              }
            }
          } 
        }
      }
    }
  }

 

 

 

0 Likes