GraphQL Schema Documentation

Comments GraphQL API

Query and mutate Comment entities linked to posts via GraphQL.

Get all comments

Fetch comments list across all blog posts.

Query / Mutation
graphql
1
query GetAllComments {
2
comments(limit: 5) {
3
id
4
post_id
5
name
6
email
7
body
8
}
9
}
Response JSON
json
1
{
2
"data": {
3
"comments": [
4
{
5
"id": "1",
6
"post_id": "1",
7
"name": "id labore ex et quam laborum",
8
"email": "Eliseo@gardner.biz",
9
"body": "laudantium enim quasi est quidem magnam voluptate ipsam eos"
10
}
11
]
12
}
13
}

Get comment with parent post

Fetch comment record along with relational parent Post object.

Query / Mutation
graphql
1
query GetCommentWithPost {
2
comment(id: "1") {
3
id
4
name
5
email
6
body
7
post {
8
id
9
title
10
}
11
}
12
}
Response JSON
json
1
{
2
"data": {
3
"comment": {
4
"id": "1",
5
"name": "id labore ex et quam laborum",
6
"email": "Eliseo@gardner.biz",
7
"body": "laudantium enim quasi...",
8
"post": {
9
"id": "1",
10
"title": "Getting Started with Playground API"
11
}
12
}
13
}
14
}

Create a comment

Add a new comment mutation linked to a post_id.

Query / Mutation
graphql
1
mutation CreateComment {
2
createComment(post_id: "1", name: "Awesome GraphQL API", email: "dev@playground.dev", body: "Fast and easy!") {
3
id
4
post_id
5
name
6
email
7
body
8
}
9
}
Response JSON
json
1
{
2
"data": {
3
"createComment": {
4
"id": "local-9b1deb4d",
5
"post_id": "1",
6
"name": "Awesome GraphQL API",
7
"email": "dev@playground.dev",
8
"body": "Fast and easy!"
9
}
10
}
11
}

Schema Comments Type

FieldTypeDescription
idID!Unique comment identifier.
post_idID!Parent post ID foreign key.
nameString!Commenter name.
emailString!Commenter email address.
bodyString!Comment text content.
postPostRelational parent Post object.