Anchor to metafieldDeletemetafield
metafieldDelete
mutationDeprecated
Deletes a metafield. This mutation will be removed in a future version. Use instead.
Anchor to Arguments
Arguments
- Anchor to inputinput•Metafield
Delete requiredInput!
Was this section helpful?
Anchor to MetafieldDeletePayload returnsMetafieldDeletePayload returns
- Anchor to deletedIddeleted•
Id The ID of the deleted metafield.
- Anchor to userErrorsuser•
Errors [UserError!]! non-null The list of errors that occurred from executing the mutation.
Was this section helpful?
- Deletes a metafield
- metafieldDelete reference
Examples
const { admin } = await authenticate.admin(request);
const response = await admin.graphql(
`#graphql
mutation metafieldDelete($input: MetafieldDeleteInput!) {
metafieldDelete(input: $input) {
deletedId
userErrors {
field
message
}
}
}`,
{
variables: {
"input": {
"id": "gid://shopify/Metafield/1069228997"
}
},
},
);
const data = await response.json();
mutation metafieldDelete($input: MetafieldDeleteInput!) {
metafieldDelete(input: $input) {
deletedId
userErrors {
field
message
}
}
}
curl -X POST \
https://your-development-store.myshopify.com/admin/api/2024-04/graphql.json \
-H 'Content-Type: application/json' \
-H 'X-Shopify-Access-Token: {access_token}' \
-d '{
"query": "mutation metafieldDelete($input: MetafieldDeleteInput!) { metafieldDelete(input: $input) { deletedId userErrors { field message } } }",
"variables": {
"input": {
"id": "gid://shopify/Metafield/1069228997"
}
}
}'
const { admin } = await authenticate.admin(request);
const response = await admin.graphql(
`#graphql
mutation metafieldDelete($input: MetafieldDeleteInput!) {
metafieldDelete(input: $input) {
deletedId
userErrors {
field
message
}
}
}`,
{
variables: {
"input": {
"id": "gid://shopify/Metafield/1069228997"
}
},
},
);
const data = await response.json();
const client = new shopify.clients.Graphql({session});
const data = await client.query({
data: {
"query": `mutation metafieldDelete($input: MetafieldDeleteInput!) {
metafieldDelete(input: $input) {
deletedId
userErrors {
field
message
}
}
}`,
"variables": {
"input": {
"id": "gid://shopify/Metafield/1069228997"
}
},
},
});
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 metafieldDelete($input: MetafieldDeleteInput!) {
metafieldDelete(input: $input) {
deletedId
userErrors {
field
message
}
}
}
QUERY
variables = {
"input": {
"id": "gid://shopify/Metafield/1069228997"
}
}
response = client.query(query: query, variables: variables)
Input variables
JSON{
"input": {
"id": "gid://shopify/Metafield/1069228997"
}
}
Response
JSON{
"metafieldDelete": {
"deletedId": "gid://shopify/Metafield/1069228997",
"userErrors": []
}
}