GraphQL - ProductVariants taxCode field error

Solved
Highlighted
New Member
2 0 0

I'm trying to do a productVariants query to get taxCodes for all my variants.  Insomnia returns this error:

Field 'taxCode' doesn't exist on type 'ProductVariant'

taxCode is a documented field, however, and I even found a thread from a couple of months ago that shows someone actually being able to get at that field: https://community.shopify.com/c/Shopify-APIs-SDKs/Search-for-null-variant-values-using-graphql-and-s...

 

So is this a new bug in the GraphQL API?  What are the chances of getting it fixed?  Or am I doing something wrong?

 

Here's an example query:

{
  productVariants(first: 1) {
    edges {
      node {
        title
        id
        sku
        taxCode
      }
    }
  }
}

And the response...

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

 

Thanks!

 

0 Likes
Highlighted
Shopify Staff (Retired)
Shopify Staff (Retired)
624 102 129

This is an accepted solution.

Hi @StefanPodell ,

 

The `taxCode` attribute of ProductVariants was only introduced to the Admin API in version 2019-10. So if you are making an API request to a version less than 2019-10, or if you are not specifying the API version at all (at which point you will default to the lowest 2019-04 version - e.g. {store-name}.myshopify.com/admin/graphql.json), you will get the error you are seeing

 

To fix this, specify API version 2019-10 or higher when you are making this GraphQL query

Hassain | Developer Support Specialist @ Shopify
 - Was my reply helpful? Click Like to let me know! 
 - Was your question answered? Click Accept as Solution 

0 Likes
Highlighted
New Member
2 0 0

Thanks, Hassain. 

0 Likes