Have your say in Community Polls: What was/is your greatest motivation to start your own business?
Our Partner & Developer boards on the community are moving to a brand new home: the .dev community forums! While you can still access past discussions here, for all your future app and storefront building questions, head over to the new forums.

Field 'metafield' doesn't exist on type 'Collection

Field 'metafield' doesn't exist on type 'Collection

himanshusatija
Visitor
3 0 0

Hi, I want to access some metafiles in the collection using storefront API but I'm not able to do that even after whitelisting meta fields. I'm getting the following error " Field 'metafield' doesn't exist on type 'Collection'".

Replies 4 (4)

Jason
Shopify Partner
11206 226 2315

This is expected behaviour. Collection metafields are not currently exposed in the Storefront API.
https://shopify.dev/docs/storefront-api/reference/common-objects/metafield#types-that-return-metafie...

★ I jump on these forums in my free time to help and share some insights. Not looking to be hired, and not looking for work. http://freakdesign.com.au ★
Jamesscaggs
Visitor
3 0 0

That’s a bummer. What is the recommended way to add custom fields to collections/pages for headless development then?

Jason
Shopify Partner
11206 226 2315

You'd need to either store the extra data in your own database. Now that might be something that you still pull from the master product via the Admin API, but it could also be something you store externally to Shopify. The source doesn't matter as you'd just be matching your DB content against that product ID in the lookup.

If metafields are supported later in the storefront API there would be some value in keeping shopify as the master record keeper so you're ready for it.

★ I jump on these forums in my free time to help and share some insights. Not looking to be hired, and not looking for work. http://freakdesign.com.au ★
Jamesscaggs
Visitor
3 0 0
Yea, the benefit of the metafield is to give the client the ability to
manage the content in Shopify. We will have to treat it as static data for
now. Thanks for the heads up.