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
1
query GetAllComments {
2
comments(limit: 5) {
3
id
4
post_id
5
name
6
email
7
body
8
}
9
}
Response 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
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
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
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
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
}
Pagination & Filtering
Filter comments by post_id, page, and limit arguments.
Paginated Query
1
query FilterComments {
2
comments(post_id: "1", page: 1, limit: 2) {
3
id
4
name
5
email
6
}
7
}
Paginated Response
1
{
2
"data": {
3
"comments": [
4
{
5
"id": "1",
6
"name": "id labore ex et quam laborum",
7
"email": "Eliseo@gardner.biz"
8
}
9
]
10
}
11
}
Query Arguments
| Argument | Type | Description |
|---|---|---|
| post_id | ID | Filter comments belonging to post ID. |
| page | Int | Page number. |
| limit | Int | Items per page. |
Schema Comments Type
| Field | Type | Description |
|---|---|---|
| id | ID! | Unique comment identifier. |
| post_id | ID! | Parent post ID foreign key. |
| name | String! | Commenter name. |
| String! | Commenter email address. | |
| body | String! | Comment text content. |
| post | Post | Relational parent Post object. |