Anchor to section titled 'undefined'

metafieldDefinitionUnpin
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 definitionId
definitionId
required

The ID of the metafield definition to unpin.


Was this section helpful?

The metafield definition that was unpinned.

The list of errors that occurred from executing the mutation.


Was this section helpful?

Examples

Hide code
DescriptionCopy
mutation metafieldDefinitionUnpin($definitionId: ID!) {
  metafieldDefinitionUnpin(definitionId: $definitionId) {
    unpinnedDefinition {
      name
      key
      namespace
      pinnedPosition
    }
    userErrors {
      field
      message
    }
  }
}
curl -X POST \
https://your-development-store.myshopify.com/admin/api/2024-01/graphql.json \
-H 'Content-Type: application/json' \
-H 'X-Shopify-Access-Token: {access_token}' \
-d '{
"query": "mutation metafieldDefinitionUnpin($definitionId: ID!) { metafieldDefinitionUnpin(definitionId: $definitionId) { unpinnedDefinition { name key namespace pinnedPosition } userErrors { field message } } }",
 "variables": {
    "definitionId": "gid://shopify/MetafieldDefinition/1071456133"
  }
}'
const { admin } = await authenticate.admin(request);

const response = await admin.graphql(
  `#graphql
  mutation metafieldDefinitionUnpin($definitionId: ID!) {
    metafieldDefinitionUnpin(definitionId: $definitionId) {
      unpinnedDefinition {
        name
        key
        namespace
        pinnedPosition
      }
      userErrors {
        field
        message
      }
    }
  }`,
  {
    variables: {
      "definitionId": "gid://shopify/MetafieldDefinition/1071456133"
    },
  },
);

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 metafieldDefinitionUnpin($definitionId: ID!) {
    metafieldDefinitionUnpin(definitionId: $definitionId) {
      unpinnedDefinition {
        name
        key
        namespace
        pinnedPosition
      }
      userErrors {
        field
        message
      }
    }
  }
QUERY

variables = {
  "definitionId": "gid://shopify/MetafieldDefinition/1071456133"
}

response = client.query(query: query, variables: variables)
const client = new shopify.clients.Graphql({session});
const data = await client.query({
  data: {
    "query": `mutation metafieldDefinitionUnpin($definitionId: ID!) {
      metafieldDefinitionUnpin(definitionId: $definitionId) {
        unpinnedDefinition {
          name
          key
          namespace
          pinnedPosition
        }
        userErrors {
          field
          message
        }
      }
    }`,
    "variables": {
      "definitionId": "gid://shopify/MetafieldDefinition/1071456133"
    },
  },
});
use Shopify\Clients\Graphql;

$client = new Graphql("your-development-store.myshopify.com", $accessToken);
$query = <<<QUERY
  mutation metafieldDefinitionUnpin($definitionId: ID!) {
    metafieldDefinitionUnpin(definitionId: $definitionId) {
      unpinnedDefinition {
        name
        key
        namespace
        pinnedPosition
      }
      userErrors {
        field
        message
      }
    }
  }
QUERY;

$variables = [
  "definitionId" => "gid://shopify/MetafieldDefinition/1071456133",
];

$response = $client->query(["query" => $query, "variables" => $variables]);
Hide code
Input variables
Copy
{
  "definitionId": "gid://shopify/MetafieldDefinition/1071456133"
}
Hide code
Response
JSON
{
  "metafieldDefinitionUnpin": {
    "unpinnedDefinition": {
      "name": "Instructions to wash your product",
      "key": "wash",
      "namespace": "instructions",
      "pinnedPosition": null
    },
    "userErrors": []
  }
}