Skip to content

A simple blog API service with GraphQl Endpoints using Graphene-Django

Notifications You must be signed in to change notification settings

balavasudevan123/blogApiService

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 

Repository files navigation

BlogApiService

A simple blog API service with GraphQl Endpoints using Graphene-Django

Tech Stacks Used:

Tasks:

  1. Implement a createPost() mutation which will create a Post (a blogpost object) with attributes {title, description, publish_date, author (just a name as TextField)}
  2. Implement a updatePost($id) mutation which will update a Post attributes by $id
  3. Implement a createComment() mutation which will create a Comment object with attributes {post (the blogpost object), text, author (just the name as a TextField)}
  4. Implement a deleteComment($id) mutation to delete the given Comment by its ID.
  5. Implement a posts() query to list all the posts
  6. Implement a post($id) query to get details of a post and all its comments

Database used:

SQlite DB

Sample GraphQL codes

#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
    } 
  }
}

About

A simple blog API service with GraphQl Endpoints using Graphene-Django

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages