Skip to main content
object

Defines the structure, validation rules, and permissions for Metafield objects attached to a specific owner type. Each definition establishes a schema that metafields must follow, including the data type and validation constraints.

The definition controls access permissions across different APIs, determines whether the metafield can be used for filtering or as a collection condition, and can be constrained to specific resource subtypes.

•MetafieldAccess!
non-null

The access settings associated with the metafield definition.

•MetafieldCapabilities!
non-null

The capabilities of the metafield definition.

•MetafieldDefinitionConstraints

The constraints that determine what subtypes of resources a metafield definition applies to.

•DateTime!
non-null

The date and time when the metafield definition was created.

•String

The description of the metafield definition.

•ID!
non-null

A globally-unique ID.

•String!
non-null

The unique identifier for the metafield definition within its namespace.

•MetafieldConnection!
non-null

The metafields that belong to the metafield definition.

Arguments

•MetafieldValidationStatus
Default:ANY

Returns the metafields filtered by the validation status.

•Int

The first n elements from the paginated list.

•String

The elements that come after the specified cursor.

•Int

The last n elements from the paginated list.

•String

The elements that come before the specified cursor.

•Boolean
Default:false

Reverse the order of the underlying list.


•Int!
non-null

The count of the metafields that belong to the metafield definition.

Arguments

•MetafieldValidationStatus

The current validation status.


•String!
non-null

The human-readable name of the metafield definition.

•String!
non-null

The container for a group of metafields that the metafield definition is associated with.

•MetafieldOwnerType!
non-null

The resource type that the metafield definition is attached to.

•Int

The position of the metafield definition in the pinned list.

•StandardMetafieldDefinitionTemplate

The standard metafield definition template associated with the metafield definition.

•MetafieldDefinitionType!
non-null

The type of data that each of the metafields that belong to the metafield definition will store. Refer to the list of supported types.

•DateTime!
non-null

The date and time when the metafield definition was updated.

Anchor to useAsCollectionConditionuseAsCollectionCondition
•Boolean!
non-null

Whether the metafield definition can be used as a collection condition.

•[MetafieldDefinitionValidation!]!
non-null

A list of validation options for the metafields that belong to the metafield definition. For example, for a metafield definition with the type date, you can set a minimum date validation so that each of the metafields that belong to it can only store dates after the specified minimum.

•MetafieldDefinitionValidationStatus!
non-null

The validation status for the metafields that belong to the metafield definition.


Was this section helpful?

•query

Retrieves a MetafieldDefinition by its identifier. You can identify a definition using either its owner type, namespace, and key, or its global ID.

Use this query to inspect a definition's configuration, including its data type, validations, access settings, and the count of metafields using it.

Arguments

•ID
Deprecated
•MetafieldDefinitionIdentifierInput

The identifier of the MetafieldDefinition to return.


•query

Returns a list of metafield definitions.

Arguments

•String

Filter metafield definition by key.

•String

Filter metafield definition by namespace.

•MetafieldOwnerType!
required

Filter the metafield definition by the specific owner type.

•MetafieldDefinitionPinnedStatus
Default:ANY

Filter the metafield definition by the pinned status.

•MetafieldDefinitionConstraintSubtypeIdentifier

Filter metafield definitions based on whether they apply to a given resource subtype.

•MetafieldDefinitionConstraintStatus

Filter metafield definitions based on whether they are constrained.

•Int

The first n elements from the paginated list.

•String

The elements that come after the specified cursor.

•Int

The last n elements from the paginated list.

•String

The elements that come before the specified cursor.

•Boolean
Default:false

Reverse the order of the underlying list.

•MetafieldDefinitionSortKeys
Default:ID

Sort the underlying list using a key. If your query is slow or returns an error, then try specifying a sort key that matches the field used in the search.

•String

A filter made up of terms, connectives, modifiers, and comparators. You can apply one or more filters to a query. Learn more about Shopify API search syntax.

Anchor to default
•string

Filter by a case-insensitive search of multiple fields in a document.

Example:

  • query=Bob Norman
  • query=title:green hoodie
Anchor to created_at
•time

Filter by the date and time when the metafield definition was created.

Example:

  • created_at:>2020-10-21T23:39:20Z
  • created_at:<now
  • created_at:<=2024
•id

Filter by id range.

Example:

  • id:1234
  • id:>=1234
  • id:<=1234
•string

Filter by the metafield definition key field.

Example:

  • key:some-key
Anchor to namespace
•string

Filter by the metafield definition namespace field.

Example:

  • namespace:some-namespace
Anchor to owner_type
•string

Filter by the metafield definition ownerType field.

Example:

  • owner_type:PRODUCT
•string

Filter by the metafield definition type field.

Example:

  • type:single_line_text_field
Anchor to updated_at
•time

Filter by the date and time when the metafield definition was last updated.

Example:

  • updated_at:>2020-10-21T23:39:20Z
  • updated_at:<now
  • updated_at:<=2024


Was this section helpful?

•mutation

Creates a MetafieldDefinition that establishes structure and validation rules for metafields. The definition specifies the data type, validation constraints, and access permissions for metafields with a given namespace and key combination.

When you create a new definition, the system validates any existing unstructured metafields matching the same owner type, namespace, and key against it. The system updates each valid metafield's type to match the definition. Invalid metafields remain unchanged but must conform to the definition when updated.

Learn more about creating metafield definitions.

Arguments

•MetafieldDefinitionInput!
required

Specifies the input fields for a metafield definition.


•mutation

You can organize your metafields in your Shopify admin by pinning/unpinning metafield definitions. The order of your pinned metafield definitions determines the order in which your metafields are displayed on the corresponding pages in your Shopify admin. By default, only pinned metafields are automatically displayed.

Arguments

•ID

The id of the metafield definition to pin. Using identifier is preferred.

•MetafieldDefinitionIdentifierInput

The identifier of the metafield definition to pin.


•mutation

You can organize your metafields in your Shopify admin by pinning/unpinning metafield definitions. The order of your pinned metafield definitions determines the order in which your metafields are displayed on the corresponding pages in your Shopify admin. By default, only pinned metafields are automatically displayed.

Arguments

•ID

The ID of the metafield definition to unpin. Using identifier is preferred.

•MetafieldDefinitionIdentifierInput

The identifier of the metafield definition to unpin.


•mutation

Updates a MetafieldDefinition's configuration and settings. You can modify the definition's name, description, validation rules, access settings, capabilities, and constraints.

The mutation updates access settings that control visibility across different APIs, such as the GraphQL Admin API, Storefront API, and Customer Account API. It also enables capabilities like admin filtering or unique value validation, and modifies constraints that determine which resource subtypes the definition applies to.


Note

The type, namespace, key, and owner type identify the definition and so can't be changed.


Learn more about updating metafield definitions.

Arguments

•MetafieldDefinitionUpdateInput!
required

The input fields for the metafield definition update.


•mutation

Activates the specified standard metafield definition from its template.

Refer to the list of standard metafield definition templates.

Arguments

•MetafieldOwnerType!
required

The resource type that the metafield definition is scoped to.

•ID

The ID of the standard metafield definition template to enable.

•String

The namespace of the standard metafield to enable. Used in combination with key.

•String

The key of the standard metafield to enable. Used in combination with namespace.

•Boolean
Default:null

Whether to pin the metafield definition.

Anchor to visibleToStorefrontApivisibleToStorefrontApi
•Boolean
DeprecatedDefault:null
Anchor to useAsCollectionConditionuseAsCollectionCondition
•Boolean
DeprecatedDefault:null
•MetafieldCapabilityCreateInput

The capabilities of the metafield definition.

•StandardMetafieldDefinitionAccessInput

The access settings that apply to each of the metafields that belong to the metafield definition.


•mutation

Enables multiple specified standard metafield definitions from their templates as a single transaction. This API is idempotent so any previously-enabled standard definitions will not cause a failure. However, invalid inputs or other user errors will prevent all of the requested definitions from being enabled.

Refer to the list of standard metafield definition templates.

Arguments

•[StandardMetafieldDefinitionsEnableInput!]!
required

The list of standard definitions to enable. Maximum of 25.



Was this section helpful?

•interface

Was this section helpful?