Metafield returns data in Admin API but null in Storefront API (worked before, now not)

Hi everyone,

I’ve run into an issue with product variant metafields in GraphQL.

  • When I query via Admin API, the metafield returns the expected value.
  • When I query via Storefront API, the same metafield is always null.
  • What’s strange is that this only started happening recently – before that, I was able to fetch the metafield value in Storefront API without any problems.

Admin API query

query {
  nodes(ids: ["gid://shopify/Product/1234567890"]) {
    ... on Product {
      variants(first: 5) {
        nodes {
          id
          title
          metafield(namespace: "custom", key: "extra_info") {
            value
          }
        }
      }
    }
  }
}

Admin API result

{
  "id": "gid://shopify/ProductVariant/1111",
  "title": "Sample Variant",
  "metafield": {
    "value": "{\"foo\":\"bar\"}"
  }
}

Storefront API query



query {
  nodes(ids: ["gid://shopify/Product/1234567890"]) {
    ... on Product {
      variants(first: 5) {
        nodes {
          id
          title
          metafield(namespace: "custom", key: "extra_info") {
            value
          }
        }
      }
    }
  }
}

Storefront API result (same variant)

{
  "id": "gid://shopify/ProductVariant/1111",
  "title": "Sample Variant",
  "metafield": null
}

Question:

  • Why does this metafield show up in Admin API but return null in Storefront API now, even though it used to work before?
  • Has something changed recently that could cause this behavior?

Thanks!

What’s Happening

  • Admin API will always show metafields, because it’s meant for store management (you, the merchant). Permissions are basically unlimited there.

  • Storefront API is customer-facing, Shopify restricts what data you can expose to the public side.

  • If a meta-field comes back as null in Storefront API, that means the meta-field exists but it isn’t published/accessible to the storefront.

Why It Used to Work (and Doesn’t Now)

Shopify recently tightened down meta-field access in the Storefront API (mid–2023 into 2024). Before, a lot of custom meta-fields just showed up by default. Now you need to explicitly “expose” meta-fields to storefronts.

So what you’re seeing isn’t a bug, it’s a permissions change.

How to Fix It

  1. Go to Shopify Admin → Settings → Custom Data → Variants (or Products)

  2. Find your metafield definition (namespace: custom, key: extra_info).

  3. Edit the definition and enable “Expose to storefront API”.

    • There’s literally a toggle for this now.
  4. Save it.

  5. Re-run your Storefront API query → you’ll get your value back.

Do you mean it only works with metafield definitions, not regular metafields?