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 of read_and_sf_access or write_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 of keys.

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
                    }
                  }
                }
              }
            }
          }
        }
      }
    }
  }
}