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
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();
mutation privateMetafieldDelete($input: PrivateMetafieldDeleteInput!) {
privateMetafieldDelete(input: $input) {
deletedPrivateMetafieldId
userErrors {
field
message
}
}
}
curl -X POST \
https://your-development-store.myshopify.com/admin/api/2024-10/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
JSON{
"input": {
"owner": "gid://shopify/Product/20995642",
"namespace": "wholesale",
"key": "price"
}
}
Response
JSON{
"privateMetafieldDelete": {
"deletedPrivateMetafieldId": "gid://shopify/PrivateMetafield/1060470839",
"userErrors": []
}
}