GraphQL Storefront API updates - Metafields on Product, Category, Brand, Variant
1589820540001
Storefront API
Enhancement
API
New features
- Metafields which have been associated with products, categories, brands, or variants can now be accessed via the GraphQL Storefront API.
- The metafield must be marked with a
permission_set
ofread_and_sf_access
orwrite_and_sf_access
in order to be exposed to the API. Metafields with any other permission value will be hidden. - A new
metafields
paginated node is available on the relevant nodes to allow access. - It is required to supply the metafield
namespace
when fetching metafields. It’s also recommended to explicitly supply a list ofkeys
.
- The metafield must be marked with a
Consider this query:
query metafields { site { products(first: 3) { edges { cursor node { metafields( namespace:"my-namespace" keys: ["my-key", "my-other-key"] first:2 ) { edges { node { key id value } } } variants(first: 5) { edges { node { sku metafields( namespace:"my-namespace" keys: ["my-key", "my-other-key"] first:2 ) { edges { node { key id value } } } } } } brand { name metafields( namespace:"my-namespace" keys: ["my-key", "my-other-key"] first:2 ) { edges { node { key id value } } } } categories { edges { node { metafields( namespace:"my-namespace" keys: ["my-key", "my-other-key"] first:2 ) { edges { node { key id value } } } } } } } } } } }