Re: Products Metafields in GraphQL API

Products Metafields in GraphQL API

Tarik_Ansari
Visitor
2 0 0

Hi, is it possible to access Products metafields in the GraphQL API? They don't appear in the schema, but would be useful for me to display product reviews, while still being able to use the Reviews App to manage reviews.

Replies 3 (3)

Alex
Shopify Staff
1561 81 342

Hey Tarik,

We consider the storefront API useful for accessing and mutating customer-facing data. Although metafield data can, for example, be pulled into a theme and presented there, we consider them to be merchant facing for the most part. As such, we don't presently offer access to metafields with the storefront API.

Cheers.

Alex | Shopify 
 - Was my reply helpful? Click Like to let me know! 
 - Was your question answered? Mark it as an Accepted Solution
 - To learn more visit the Shopify Help Center or the Shopify Blog

Tarik_Ansari
Visitor
2 0 0

Any other way to access metafields to display product reviews for a customer-facing Storefront? I understand your explanation, but it's only a piece of the answer, since reviews are being stored there, and liquid themes have access to them.

Alex
Shopify Staff
1561 81 342

Hey Tarik,

To give you an example of how our product reviews app works:

We store product reviews in metafields like what you want to do. During our install flow for the app, we tell the customer to place a snippet in their theme where they want the reviews to be displayed (this could be bypassed if you make use of script tags, theme, or assets APIs dependign on your approach). This snippet looks like this:

<div id="shopify-product-reviews" data-id="{{product.id}}">{{ product.metafields.spr.reviews }}</div>

The liquid itself is what accesses the metafields which hold the unique product reviews.

I hope that helps.

Cheers.

Alex | Shopify 
 - Was my reply helpful? Click Like to let me know! 
 - Was your question answered? Mark it as an Accepted Solution
 - To learn more visit the Shopify Help Center or the Shopify Blog