Anchor to metafieldDefinitionPinmetafield
metafieldDefinitionPin
mutation
Requires API client to have access to the namespace and the resource type associated with the metafield definition.
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.
Anchor to Arguments
Arguments
- Anchor to definitionIddefinition•
Id ID!required The ID of the metafield definition to pin.
Was this section helpful?
Anchor to MetafieldDefinitionPinPayload returnsMetafieldDefinitionPinPayload returns
- Anchor to pinnedDefinitionpinned•
Definition The metafield definition that was pinned.
- Anchor to userErrorsuser•
Errors The list of errors that occurred from executing the mutation.
Was this section helpful?
1const { admin } = await authenticate.admin(request);23const response = await admin.graphql(4 `#graphql5 mutation metafieldDefinitionPin($definitionId: ID!) {6 metafieldDefinitionPin(definitionId: $definitionId) {7 pinnedDefinition {8 name9 key10 namespace11 pinnedPosition12 }13 userErrors {14 field15 message16 }17 }18 }`,19 {20 variables: {21 "definitionId": "gid://shopify/MetafieldDefinition/1071456171"22 },23 },24);2526const data = await response.json();27
mutation metafieldDefinitionPin($definitionId: ID!) {
metafieldDefinitionPin(definitionId: $definitionId) {
pinnedDefinition {
name
key
namespace
pinnedPosition
}
userErrors {
field
message
}
}
}
curl -X POST \
https://your-development-store.myshopify.com/admin/api/2025-01/graphql.json \
-H 'Content-Type: application/json' \
-H 'X-Shopify-Access-Token: {access_token}' \
-d '{
"query": "mutation metafieldDefinitionPin($definitionId: ID!) { metafieldDefinitionPin(definitionId: $definitionId) { pinnedDefinition { name key namespace pinnedPosition } userErrors { field message } } }",
"variables": {
"definitionId": "gid://shopify/MetafieldDefinition/1071456171"
}
}'
const { admin } = await authenticate.admin(request);
const response = await admin.graphql(
`#graphql
mutation metafieldDefinitionPin($definitionId: ID!) {
metafieldDefinitionPin(definitionId: $definitionId) {
pinnedDefinition {
name
key
namespace
pinnedPosition
}
userErrors {
field
message
}
}
}`,
{
variables: {
"definitionId": "gid://shopify/MetafieldDefinition/1071456171"
},
},
);
const data = await response.json();
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
mutation metafieldDefinitionPin($definitionId: ID!) {
metafieldDefinitionPin(definitionId: $definitionId) {
pinnedDefinition {
name
key
namespace
pinnedPosition
}
userErrors {
field
message
}
}
}
QUERY
variables = {
"definitionId": "gid://shopify/MetafieldDefinition/1071456171"
}
response = client.query(query: query, variables: variables)
const client = new shopify.clients.Graphql({session});
const data = await client.query({
data: {
"query": `mutation metafieldDefinitionPin($definitionId: ID!) {
metafieldDefinitionPin(definitionId: $definitionId) {
pinnedDefinition {
name
key
namespace
pinnedPosition
}
userErrors {
field
message
}
}
}`,
"variables": {
"definitionId": "gid://shopify/MetafieldDefinition/1071456171"
},
},
});
Input variables
JSON1{2 "definitionId": "gid://shopify/MetafieldDefinition/1071456171"3}
Response
JSON1{2 "metafieldDefinitionPin": {3 "pinnedDefinition": {4 "name": "Instructions to wash your product",5 "key": "wash",6 "namespace": "instructions",7 "pinnedPosition": 18 },9 "userErrors": []10 }11}