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
| Field | Type | Description |
|---|---|---|
postId | String! | Post ID for which the comment is created |
text | String! | 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. |
notifyOP | Boolean | Whether to notify the original post author |
notifyCommenters | Boolean | Whether to notify other commenters |
notifyUpVoters | Boolean | Whether to notify users who upvoted |
notifyDownVoters | Boolean | Whether to notify users who downvoted |
notifySubscribers | Boolean | Whether 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
| Field | Type | Description |
|---|---|---|
id | String! | Comment ID |
moderationStatus | CommentModerationStatus! | New moderation status |
CommentModerationStatus Enum
| Value | Description |
|---|---|
APPROVED | Comment has been approved |
REJECTED | Comment has been rejected |
FLAGGED | Comment has been flagged for review |
PENDING | Comment 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
| Field | Type | Description |
|---|---|---|
id | String! | 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
| Field | Type | Description |
|---|---|---|
id | String! | Comment ID |
type | CommentLikeType! | Type of like action |
CommentLikeType Enum
| Value | Description |
|---|---|
UP | Like the comment |
CANCEL | Remove 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
| Field | Type | Description |
|---|---|---|
id | String! | Comment ID |
text | String! | 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"]
}
]
}