Metafield - admin-graphql - OBJECT
Version: 2024-01
Description:
Metafields enable you to attach additional information to a Shopify resource, such as a [Product](https://shopify.dev/api/admin-graphql/latest/objects/product) or a [Collection](https://shopify.dev/api/admin-graphql/latest/objects/collection).
For more information about where you can attach metafields refer to [HasMetafields](https://shopify.dev/api/admin/graphql/reference/common-objects/HasMetafields).
Some examples of the data that metafields enable you to store are specifications, size charts, downloadable documents, release dates, images, or part numbers.
Metafields are identified by an owner resource, namespace, and key. and store a value along with type information for that value.
Access Scopes
Fields
-
createdAt:
DateTime! -
The date and time when the metafield was created.
-
definition:
MetafieldDefinition -
The metafield definition that the metafield belongs to, if any.
-
description:
String -
The description of the metafield.
-
id:
ID! -
A globally-unique ID.
-
key:
String! -
The unique identifier for the metafield within its namespace.
-
legacyResourceId:
UnsignedInt64! -
The ID of the corresponding resource in the REST Admin API.
-
namespace:
String! -
The container for a group of metafields that the metafield is associated with.
-
owner:
HasMetafields! -
The resource that the metafield is attached to.
-
ownerType:
MetafieldOwnerType! -
The type of resource that the metafield is attached to.
-
reference:
MetafieldReference -
Returns a reference object if the metafield definition's type is a resource reference.
-
type:
String! -
The type of data that is stored in the metafield.
Refer to the list of [supported types](https://shopify.dev/apps/metafields/types).
-
updatedAt:
DateTime! -
The date and time when the metafield was updated.
-
value:
String! -
The data stored in the metafield. Always stored as a string, regardless of the metafield's type.
Connections
Related queries
Related mutations
-
metafieldsSet
Sets metafield values. Metafield values will be set regardless if they were previously created or not.
Allows a maximum of 25 metafields to be set at a time.
This operation is atomic, meaning no changes are persisted if an error is encountered.
As of `2024-07`, this operation supports compare-and-set functionality to better handle concurrent requests.
If `compareDigest` is set for any metafield, the mutation will only set that metafield if the persisted metafield value matches the digest used on `compareDigest`.
If the metafield doesn't exist yet, but you want to guarantee that the operation will run in a safe manner, set `compareDigest` to `null`.
The `compareDigest` value can be acquired by querying the metafield object and selecting `compareDigest` as a field.
If the `compareDigest` value does not match the digest for the persisted value, the mutation will return an error.
You can opt out of write guarantees by not sending `compareDigest` in the request.
Related Unions
Examples