Comment Mutations
Create Comment
Add a new comment to a post.
mutation CreateComment($postId: String!, $text: String!) {
createComment(postId: $postId, text: $text) {
node {
id
text
dateCreated
author {
id
name
}
}
}
}
Variables
{
"postId": "post-123",
"text": "This is a new comment"
}
Like Comment
Add a like to a comment.
mutation LikeComment($commentId: String!, $type: CommentLikeType = UP) {
likeComment(commentId: $commentId, type: $type) {
node {
id
likeCount
}
}
}
Variables
{
"commentId": "comment-123"
}
Update Comment Visibility
Change a comment's visibility between public and private.
mutation UpdateCommentVisibility($id: String!, $visibility: Visibility!) {
updateCommentVisibility(id: $id, visibility: $visibility) {
node {
id
visibility
}
}
}
Variables
{
"id": "comment-123",
"visibility": "PRIVATE"
}
Delete Comment
Delete an existing comment.
mutation DeleteComment($id: String!) {
deleteComment(id: $id) {
success
}
}
Variables
{
"id": "comment-123"
}
Error Responses
Common error responses include:
401- Not authenticated403- Insufficient permissions404- Comment not found429- Rate limit exceeded
For detailed error information, check the errors array in the response:
{
"errors": [
{
"message": "Comment not found",
"extensions": {
"code": "NOT_FOUND"
}
}
]
}