A space to discuss GraphQL queries, mutations, troubleshooting, throttling, and best practices.
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:
Here are my metafield directives to show they are also being queried for correctly:
But alas, no luck at all:
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.
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.