Anchor to metafieldDefinitionTypesmetafield
metafieldDefinitionTypes
query
Each metafield definition has a type, which defines the type of information that it can store. This type is enforced across every instance of the resource that owns the metafield definition.
Refer to the list of supported metafield types.
Anchor to Possible returnsPossible returns
- Anchor to MetafieldDefinitionTypeMetafield•
Definition Type A metafield definition type provides basic foundation and validation for a metafield.
- category•String!non-null
The category associated with the metafield definition type.
- name•String!non-null
The name of the type for the metafield definition. See the list of supported types.
- supported
Validations •[Metafieldnon-nullDefinition Supported Validation!]! The supported validations for a metafield definition type.
- supports
Definition •Migrations Boolean!non-null Whether metafields without a definition can be migrated to a definition of this type.
- value
Type •Metafieldnon-nullDeprecatedValue Type! The value type for a metafield created with this definition type.
is deprecated and
name
should be used for type information.
- category•
Was this section helpful?
Fetch all metafield definition types
const { admin } = await authenticate.admin(request);
const response = await admin.graphql(
`#graphql
query MetafieldDefinitionTypes {
metafieldDefinitionTypes {
category
name
supportsDefinitionMigrations
supportedValidations {
name
type
}
}
}`,
);
const data = await response.json();
query MetafieldDefinitionTypes {
metafieldDefinitionTypes {
category
name
supportsDefinitionMigrations
supportedValidations {
name
type
}
}
}
curl -X POST \
https://your-development-store.myshopify.com/admin/api/unstable/graphql.json \
-H 'Content-Type: application/json' \
-H 'X-Shopify-Access-Token: {access_token}' \
-d '{
"query": "query MetafieldDefinitionTypes { metafieldDefinitionTypes { category name supportsDefinitionMigrations supportedValidations { name type } } }"
}'
const { admin } = await authenticate.admin(request);
const response = await admin.graphql(
`#graphql
query MetafieldDefinitionTypes {
metafieldDefinitionTypes {
category
name
supportsDefinitionMigrations
supportedValidations {
name
type
}
}
}`,
);
const data = await response.json();
const client = new shopify.clients.Graphql({session});
const data = await client.query({
data: `query MetafieldDefinitionTypes {
metafieldDefinitionTypes {
category
name
supportsDefinitionMigrations
supportedValidations {
name
type
}
}
}`,
});
session = ShopifyAPI::Auth::Session.new(
shop: "your-development-store.myshopify.com",
access_token: access_token
)
client = ShopifyAPI::Clients::Graphql::Admin.new(
session: session
)
query = <<~QUERY
query MetafieldDefinitionTypes {
metafieldDefinitionTypes {
category
name
supportsDefinitionMigrations
supportedValidations {
name
type
}
}
}
QUERY
response = client.query(query: query)
Response
JSON{
"metafieldDefinitionTypes": [
{
"category": "TRUE_FALSE",
"name": "boolean",
"supportsDefinitionMigrations": true,
"supportedValidations": []
},
{
"category": "COLOR",
"name": "color",
"supportsDefinitionMigrations": true,
"supportedValidations": []
},
{
"category": "DATE_TIME",
"name": "date_time",
"supportsDefinitionMigrations": true,
"supportedValidations": [
{
"name": "min",
"type": "date_time"
},
{
"name": "max",
"type": "date_time"
}
]
},
{
"category": "DATE_TIME",