Get product by variantmetafield

Hi,

what exactly do I have to change here so that I can query the variantmetafield correctly?

fetch('https://xxxx.myshopify.com/api/2025-04/graphql', {
  method: 'POST',
  headers: {
    'Content-Type': 'application/json',
    'X-Shopify-Storefront-Access-Token': 'xxx',
  },
  body: JSON.stringify({
    query: `query Products {
      products(first: 1, query: "metafields.itemid.itemid:'1947'") {
        edges {
          node {
            id
            title
          }
        }
      }
    }`,
  }),
})
  .then((response) => response.json())
  .then((data) => {
    console.log('prod:', data);
  })
  .catch((error) => console.error('Fehler:', error));

Thanks :slight_smile:

Hi there, I do not believe it is possible to query products based on a variant metafield. You can instead query by the product level and its metafield.

Have a read of these docs:

Hi @Luke,

thanks for your answer, don’t really know what you mean, i got my code from this guide.

BG

Just to clarify, the code in the guide is for querying a product metafield. Currently, it’s not possible to make productVariant metafields filterable

1 Like