Anchor to privateMetafieldDeleteprivate
privateMetafieldDelete
mutationDeprecated
Deletes a private metafield. Private metafields are automatically deleted when the app that created them is uninstalled. Metafields created using a reserved namespace are private by default. See our guide for migrating private metafields.
Anchor to Arguments
Arguments
- Anchor to inputinput•Private
Metafield requiredDelete Input! The input fields for the private metafield to delete.
Was this section helpful?
Anchor to PrivateMetafieldDeletePayload returnsPrivateMetafieldDeletePayload returns
- Anchor to deletedPrivateMetafieldIddeleted•
Private Metafield Id The ID of private metafield that was deleted.
- Anchor to userErrorsuser•
Errors [UserError!]! non-null The list of errors that occurred from executing the mutation.
Was this section helpful?
- Delete a private metafield owned by the Product resource
- Delete a private metafield owned by the Shop resource
- privateMetafieldDelete reference
Examples
1const { admin } = await authenticate.admin(request);23const response = await admin.graphql(4 `#graphql5 mutation privateMetafieldDelete($input: PrivateMetafieldDeleteInput!) {6 privateMetafieldDelete(input: $input) {7 deletedPrivateMetafieldId8 userErrors {9 field10 message11 }12 }13 }`,14 {15 variables: {16 "input": {17 "owner": "gid://shopify/Product/20995642",18 "namespace": "wholesale",19 "key": "price"20 }21 },22 },23);2425const data = await response.json();26
mutation privateMetafieldDelete($input: PrivateMetafieldDeleteInput!) {
privateMetafieldDelete(input: $input) {
deletedPrivateMetafieldId
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 privateMetafieldDelete($input: PrivateMetafieldDeleteInput!) { privateMetafieldDelete(input: $input) { deletedPrivateMetafieldId userErrors { field message } } }",
"variables": {
"input": {
"owner": "gid://shopify/Product/20995642",
"namespace": "wholesale",
"key": "price"
}
}
}'
const { admin } = await authenticate.admin(request);
const response = await admin.graphql(
`#graphql
mutation privateMetafieldDelete($input: PrivateMetafieldDeleteInput!) {
privateMetafieldDelete(input: $input) {
deletedPrivateMetafieldId
userErrors {
field
message
}
}
}`,
{
variables: {
"input": {
"owner": "gid://shopify/Product/20995642",
"namespace": "wholesale",
"key": "price"
}
},
},
);
const data = await response.json();
const client = new shopify.clients.Graphql({session});
const data = await client.query({
data: {
"query": `mutation privateMetafieldDelete($input: PrivateMetafieldDeleteInput!) {
privateMetafieldDelete(input: $input) {
deletedPrivateMetafieldId
userErrors {
field
message
}
}
}`,
"variables": {
"input": {
"owner": "gid://shopify/Product/20995642",
"namespace": "wholesale",
"key": "price"
}
},
},
});
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 privateMetafieldDelete($input: PrivateMetafieldDeleteInput!) {
privateMetafieldDelete(input: $input) {
deletedPrivateMetafieldId
userErrors {
field
message
}
}
}
QUERY
variables = {
"input": {
"owner": "gid://shopify/Product/20995642",
"namespace": "wholesale",
"key": "price"
}
}
response = client.query(query: query, variables: variables)
Input variables
JSON1{2 "input": {3 "owner": "gid://shopify/Product/20995642",4 "namespace": "wholesale",5 "key": "price"6 }7}
Response
JSON1{2 "privateMetafieldDelete": {3 "deletedPrivateMetafieldId": "gid://shopify/PrivateMetafield/1060470839",4 "userErrors": []5 }6}