Migrate metafields
In the 2021-07
API version release, the value_type
field on the Metafield
object was deprecated. As of the 2022-01
API version release, the value_type
field has been removed from these APIs.
- In the REST Admin API, the
type
property replaces thevalue_type
property in theMetafield
resource. - In the GraphQL Admin API, the
type
field replaces thevalueType
field in theMetafield
object.
This guide describes how you can migrate your metafields from using value_type
to type
in the REST Admin API and GraphQL Admin API.
How it works
Anchor link to section titled "How it works"For backward compatibility, when metafields that use the new types are queried from API version 2021-04
or earlier, we return a backward-mapped value type. For example, the date
type maps to the STRING
value type.
The new type
attribute also accepts deprecated value types. You can update the field name and keep the same value to avoid breaking other integrations (such as Liquid in themes). However, when adding new metafields, we recommend using the new types.
Migrate your metafields in the REST Admin API
Anchor link to section titled "Migrate your metafields in the REST Admin API"Change the value_type
property to type
in your Metafield
resource, as shown in the following example:
Migrate your metafields in the GraphQL Admin API
Anchor link to section titled "Migrate your metafields in the GraphQL Admin API"Change the valueType
field to type
in your Metafield
object, as shown in the following example:
To learn more about using Shopify APIs to work with metafields, refer to the following documentation: