Skip to main content

Comment Mutations

Create Comment

Create a new comment on a post.

Mutation Structure

mutation CreateComment(
$postId: String!
$text: String!
$files: [String]
$notifyOP: Boolean
$notifyCommenters: Boolean
$notifyUpVoters: Boolean
$notifyDownVoters: Boolean
$notifySubscribers: Boolean
) {
createComment(
postId: $postId
text: $text
files: $files
notifyOP: $notifyOP
notifyCommenters: $notifyCommenters
notifyUpVoters: $notifyUpVoters
notifyDownVoters: $notifyDownVoters
notifySubscribers: $notifySubscribers
) {
id
text
dateCreated
user {
ssoId
name
}
}
}

Input Fields

FieldTypeDescription
postIdString!Post ID for which the comment is created
textString!Text of the comment
files[String]Files attached to comment (optional). List of file IDs should only be sent after uploading the files. For uploading guide, refer files section.
notifyOPBooleanWhether to notify the original post author
notifyCommentersBooleanWhether to notify other commenters
notifyUpVotersBooleanWhether to notify users who upvoted
notifyDownVotersBooleanWhether to notify users who downvoted
notifySubscribersBooleanWhether to notify post subscribers

Change Comment Moderation Status

Change the moderation status of a comment.

Mutation Structure

mutation ChangeCommentModerationStatus($id: String!, $moderationStatus: CommentModerationStatus!) {
changeCommentModerationStatus(id: $id, moderationStatus: $moderationStatus) {
id
moderationStatus
moderator {
ssoId
name
}
}
}

Input Fields

FieldTypeDescription
idString!Comment ID
moderationStatusCommentModerationStatus!New moderation status

CommentModerationStatus Enum

ValueDescription
APPROVEDComment has been approved
REJECTEDComment has been rejected
FLAGGEDComment has been flagged for review
PENDINGComment is pending moderation

Delete Comment

Delete a comment. Note that the first comment on a post cannot be deleted as it serves as the post's description.

Mutation Structure

mutation DeleteComment($id: String!) {
deleteComment(id: $id) {
id
}
}

Input Fields

FieldTypeDescription
idString!Comment ID

Example

mutation {
deleteComment(id: "comment_123") {
id
}
}

Example Response:

{
"data": {
"deleteComment": {
"id": "comment_123"
}
}
}

Restrictions

  • The first comment on a post cannot be deleted as it serves as the post's description
  • Only comments from SSO users can be deleted
  • Comments can only be deleted from the board associated with your API key

Error Cases

The mutation may fail with the following errors:

  • "The first comment on a post cannot be deleted" - When attempting to delete the initial comment
  • "Comment not found" - When the comment doesn't exist, belongs to a different board, or is from a non-SSO user
  • "Write access required" - When the API key doesn't have write permissions

Example Error Response:

{
"errors": [
{
"message": "The first comment on a post cannot be deleted",
"path": ["deleteComment"]
}
]
}

Like Comment

Like or unlike a comment.

Mutation Structure

mutation LikeComment($id: String!, $type: CommentLikeType!) {
likeComment(id: $id, type: $type)
}

Input Fields

FieldTypeDescription
idString!Comment ID
typeCommentLikeType!Type of like action

CommentLikeType Enum

ValueDescription
UPLike the comment
CANCELRemove like from the comment

Update Comment

Update an existing comment.

Mutation Structure

mutation UpdateComment($id: String!, $text: String!, $files: [String]) {
updateComment(id: $id, text: $text, files: $files) {
id
text
files {
id
url
}
}
}

Input Fields

FieldTypeDescription
idString!Comment ID
textString!New text for the comment
files[String]Files attached to comment (optional). List of file IDs should only be sent after uploading the files. For uploading guide, refer files section. NOTE - old files will be deleted if new files are sent so send all the file IDs again if you want to keep the old files.

Authentication

All comment mutations require authentication. You must include your API key and SSO information in the HTTP headers:

{
"apikey": "YOUR_API_KEY",
"ssotype": "YOUR_SSO_TYPE",
"ssoid": "YOUR_SSO_ID"
}

Error Handling

The mutations may return errors in the following cases:

  • Invalid API key
  • Missing SSO type in headers
  • Missing SSO ID in headers
  • Write access required
  • User not found
  • Comment not found
  • Board not found
  • Invalid moderation status

Example error responses:

{
"errors": [
{
"message": "Write access required",
"path": ["createComment"]
}
]
}
{
"errors": [
{
"message": "Comment not found",
"path": ["deleteComment"]
}
]
}