Solved

Querying metafields on Release Candidate (2021-07) is not returning the expected results

hnknmzshop
Tourist
6 1 2

Hello,

I am currently trying to use the Release Candidate (2021-07) for the Storefront API. The documentation and release notes are mentioning that I should be able to retrieve metafields from i.e. Pages now, which is what I'm trying to do. However, trying to query either the metafields connection or the metafield field it doesn't work, where the former just returns an empty edges array and the latter a null value.

Do I still need to go through the process of sending an initial mutation where I set the visibility of those metafields? I'm trying to do this all on the frontend so if there is a way to do this without going through the Admin API (which will require extra work on our proxy service), I would be very happy to hear about this.

I hope this explains the issue clearly enough and if not, just let me know.

Kind regards

 

 

Accepted Solution (1)

JBakerAtShopify
Shopify Staff
1 1 1

This is an accepted solution.

Hi there,

You are correct that in order to access a metafield via the Storefront API you must first allow it via the Admin API. This goes for all types that support metafields, including the Page resource. More information can be found in this tutorial: https://shopify.dev/tutorials/retrieve-metafields-with-storefront-api#expose-metafields-to-the-store...

Hope this helps!

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

View solution in original post

Reply 1 (1)

JBakerAtShopify
Shopify Staff
1 1 1

This is an accepted solution.

Hi there,

You are correct that in order to access a metafield via the Storefront API you must first allow it via the Admin API. This goes for all types that support metafields, including the Page resource. More information can be found in this tutorial: https://shopify.dev/tutorials/retrieve-metafields-with-storefront-api#expose-metafields-to-the-store...

Hope this helps!

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