Metafields Not Showing Up In API - Possible Bug

Metafields Not Showing Up In API - Possible Bug

kindconscious
Visitor
1 0 0

So, I'm currently trying to understand why some product metafields are not coming back correct as given by a Product.

 

I have the following query:

 

query GetProductById {
  product(id: "gid://shopify/Product/7392192659615") {
    metafields(first: 100) {
      edges {
        node {
          namespace
          key
          value
        }
      }
    }
    careInstructions: metafield(namespace: "my_fields", key: "care_instructions") {
      value
    }
    ingredients: metafield(namespace: "my_fields", key: "ingredients") {
      value
    }
    bCorporation: metafield(namespace: "my_fields", key: "b_corporation") {
      value
    }
    bpaFree: metafield(namespace: "my_fields", key: "bpa_free") {
      value
    }
  }
}

I also have the following definitions for the above product ID as:

 

Screenshot 2022-11-07 at 16.12.46.png

 

Here are my metafield directives to show they are also being queried for correctly:

 

Screenshot 2022-11-07 at 16.12.33.png

 

But alas, no luck at all:

 

Screenshot 2022-11-07 at 16.14.27.png

 

Why are metafields just not working through the API? Is there some sort of caching going on?

 

I've tried in both the Admin API and the Storefront API and both are returning the same issue. 

Reply 1 (1)

abhiteshs
Shopify Staff
5 3 3

It looks like you might not have metafields associated with this product. Metafield with the key b_corporation is working fine.

To learn more visit the Shopify Help Center or the Community Blog.