Anchor to commentDeletecomment
commentDelete
mutation
Requires Any of ,
access scopes.
Deletes a comment.
Anchor to Arguments
Arguments
- •ID!required
The ID of the comment to be deleted.
Was this section helpful?
Anchor to CommentDeletePayload returnsCommentDeletePayload returns
- Anchor to deletedCommentIddeleted•
Comment Id The ID of the comment that was deleted.
- Anchor to userErrorsuser•
Errors [CommentDelete non-nullUser Error!]! The list of errors that occurred from executing the mutation.
Was this section helpful?
- Removes a comment
- commentDelete reference
Examples
const { admin } = await authenticate.admin(request);
const response = await admin.graphql(
`#graphql
mutation CommentDelete($id: ID!) {
commentDelete(id: $id) {
deletedCommentId
userErrors {
code
field
message
}
}
}`,
{
variables: {
"id": "gid://shopify/Comment/757536350"
},
},
);
const data = await response.json();
mutation CommentDelete($id: ID!) {
commentDelete(id: $id) {
deletedCommentId
userErrors {
code
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 CommentDelete($id: ID!) { commentDelete(id: $id) { deletedCommentId userErrors { code field message } } }",
"variables": {
"id": "gid://shopify/Comment/757536350"
}
}'
const { admin } = await authenticate.admin(request);
const response = await admin.graphql(
`#graphql
mutation CommentDelete($id: ID!) {
commentDelete(id: $id) {
deletedCommentId
userErrors {
code
field
message
}
}
}`,
{
variables: {
"id": "gid://shopify/Comment/757536350"
},
},
);
const data = await response.json();
const client = new shopify.clients.Graphql({session});
const data = await client.query({
data: {
"query": `mutation CommentDelete($id: ID!) {
commentDelete(id: $id) {
deletedCommentId
userErrors {
code
field
message
}
}
}`,
"variables": {
"id": "gid://shopify/Comment/757536350"
},
},
});
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 CommentDelete($id: ID!) {
commentDelete(id: $id) {
deletedCommentId
userErrors {
code
field
message
}
}
}
QUERY
variables = {
"id": "gid://shopify/Comment/757536350"
}
response = client.query(query: query, variables: variables)
Input variables
JSON{
"id": "gid://shopify/Comment/757536350"
}
Response
JSON{
"commentDelete": {
"deletedCommentId": "gid://shopify/Comment/757536350",
"userErrors": []
}
}