A simple blog API service with GraphQl Endpoints using Graphene-Django
- Implement a
createPost()
mutation which will create aPost
(a blogpost object) with attributes {title
,description
,publish_date
,author
(just a name as TextField)} - Implement a
updatePost($id)
mutation which will update aPost
attributes by$id
- Implement a
createComment()
mutation which will create aComment
object with attributes {post
(the blogpost object),text
,author
(just the name as a TextField)} - Implement a
deleteComment($id)
mutation to delete the givenComment
by its ID. - Implement a
posts()
query to list all the posts - Implement a
post($id)
query to get details of a post and all its comments
SQlite DB
#Create Post
mutation createMutation {
createPost(postData: {title: "Graphene Basics", description: "About Graphene", publishDate: "2021-11-15", author: "Bala Vasudevan"}) {
posts{
title,
description,
publishDate,
author
}
}
}
#Update Post
mutation updateMutation {
updatePost(postData: {id: 4, title: "Django Basics", description: "About Django Framework", publishDate: "2021-11-15", author: "Sabari"}) {
posts {
title,
description,
publishDate,
author
}
}
}
#Add a new comment
mutation add_comment{
addComment(postCommentData: {postIdMapping: 4, author: "SabariNathan005", comment: "Good One bro"}) {
postComments{
author
comment
createdAt
}
}
}
#Delete a comment using ID
mutation delete_comment{
deleteComment(id: 8) {
comments {
author
comment
}
}
}
#View all posts with the comments
query{
allPosts{
id
title
description
publishDate
author
commentSet{
id
author
comment
createdAt
}
}
}
#View a specific post with postId
query {
post(postId: 4) {
id
title
description
publishDate
author
commentSet{
id
author
comment
createdAt
}
}
}
#Delete an existing post with comments using post ID
mutation deleteMutation{
deletePost(id: 3) {
posts {
id
}
}
}