In this guide, you will learn about how to create a blog article along with the addition of the coauthors.
The BlogAuthor role must be assigned to you by the Administrator.
Requirements
- Open the blog board where you want to create a blog article.
- Identify the ID of the blog board from the URL of the board as described in the Create a Forum.
- Ensure that you have the necessary permission to create the blog article granted by the Administrator.
- Create a POST request to create a blog article.
Example
In this example, we are going to create a blog along with a coauthor on a blog board. You must use the contributionMethod
parameter and set it to EXPLICIT_ADD
to add a coauthor. To remove the coauthor, you must set it to EXPLICIT_REMOVE
.
Here is a POST GraphQL Mutation request and response for the blog.
GraphQL Mutation
mutation createBlogArticle($createInput: CreateBlogArticleInput!) {
createBlogArticle(createInput: $createInput) {
result {
id
subject
body
board {
id
creationId
creationDate
conversationStyle
}
contentWorkflow {
state
}
coAuthors {
totalCount
pageInfo {
hasPreviousPage
hasNextPage
}
edges {
node {
id
}
}
}
contributors {
totalCount
pageInfo {
hasPreviousPage
hasNextPage
}
edges {
node {
id
}
}
}
}
errors {
__typename
}
}
}
The variables to accommodate the GraphQL mutation are given below.
GraphQL Variables
{
"createInput":{
"subject":"simple clear prick again",
"body": "fine body content",
"teaser": "fine teaser",
"introduction": "intro simple",
"board":{
"id":"board:jitiendran-blog"
},
"contentWorkflowAction": {
"workflowAction": "SAVE_DRAFT"
},
"coAuthors": [
{
"user": {
"id": "user:5"
},
"contributionMethod": "EXPLICIT_ADD"
}
]
}
}
Here is the GraphQL Response to the request.
GraphQL Response
{
"data": {
"createBlogArticle": {
"result": {
"id": "message:463",
"subject": "simple clear prick again",
"body": "fine body content",
"board": {
"id": "board:jitiendran-blog",
"creationId": "60",
"creationDate": "2023-08-11T12:27:11.909+05:30",
"conversationStyle": "BLOG"
},
"contentWorkflow": {
"state": "DRAFT"
},
"coAuthors": {
"totalCount": 32,
"pageInfo": {
"hasPreviousPage": false,
"hasNextPage": false
},
"edges": [
{
"node": {
"id": "user:5"
}
}
]
},
"contributors": {
"totalCount": 32,
"pageInfo": {
"hasPreviousPage": false,
"hasNextPage": false
},
"edges": []
}
},
"errors": null
}
}
}
ATLAS
Comments