How to get all product variants metafields

If you are looking for any metafields at the variant level then you need to iterate through products, and then drill into the variants to get to them. Like this stripped-down example below. I just pull the first 5 products, iterate through each product’s first 5 variants, and finally iterate through each variant’s first 5 metafields. Does this work for you?

{
  products(first: 5) {
    edges {
      node {
        id
        title        
        variants(first: 5) {
          edges {
            node {
              id
              title
              metafields(first: 5) {
                edges {
                  node {
                    description
                    value
                    valueType
                  }
                }
              }
            }
          }
        }
      }
    }
  }
}
1 Like