Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/devignesh/graphql-django
This is simple blog post app using django and graphql
https://github.com/devignesh/graphql-django
django graphene-django graphql python
Last synced: 3 months ago
JSON representation
This is simple blog post app using django and graphql
- Host: GitHub
- URL: https://github.com/devignesh/graphql-django
- Owner: devignesh
- Created: 2020-03-02T19:50:21.000Z (almost 5 years ago)
- Default Branch: master
- Last Pushed: 2023-08-18T05:10:05.000Z (over 1 year ago)
- Last Synced: 2023-08-18T06:49:00.094Z (over 1 year ago)
- Topics: django, graphene-django, graphql, python
- Language: Python
- Size: 37.1 KB
- Stars: 4
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# graphQL-Django
This is simple blog post app using django and graphQL, We design an api schema for blogpost and comment.
In graphQL Queries and mutation is used for getting data and changing data in server.
Graphene we can use Django to create GraphQL APIs.
--------------------------------------------------------
# Start the project
Clone the repository :
1: git clone [email protected]:devignesh/graphQL-Django.git
2: cd graphQL-Django
I. pipenv shell
II. pipenv install
III. cd blog # app name
3: python manage.py makemigrations
4: python mange.py migrate
5: python mange.py runserver
6: http://127.0.0.1:8000/graphql/ #open in your browser
----------------------------------------------------------
# queries
To get all the blog post
----------------------------------------------------------query {
blogpostall {
id
author
title
description
publishedDate
updatedAt
}
}To get the blogpost with Comments
----------------------------------------------------------query {
blogpostall {
id
author
title
description
publishedDate
updatedAt
commentSet {
id
comment
}}
}
# Response
{
"data": {
"blogpostall": [
{
"id": "1",
"author": "vignesh",
"title": "Python Django",
"description": "Sample Blog",
"publishedDate": "2020-03-03T02:31:22+00:00",
"updatedAt": null,
"commentSet": [
{
"id": "13",
"comment": "comment"
},
{
"id": "3",
"comment": "Third comment"
}
]
},
{
"id": "2",
"author": "vicky",
"title": "Django graphQL",
"description": "Django testing",
"publishedDate": "2020-03-02T21:04:18.194415+00:00",
"updatedAt": null,
"commentSet": [
{
"id": "19",
"comment": "test"
},
{
"id": "16",
"comment": "vv"
},
{
"id": "15",
"comment": "vv"
},
{
"id": "14",
"comment": "vv"
},
{
"id": "12",
"comment": "value"
},
{
"id": "5",
"comment": "File performance"
},
{
"id": "4",
"comment": "Mannual data"
}
]
}
}Query for get the particular blogpost and comments based on its ID
---------------------------------------------------------------------query {
blogs(id:1) {
id
author
title
description
publishedDate
commentSet {
id
comment
}}
}# Mutation
Create a new blog post mutation
----------------------------------------------------------mutation {
createBlog (author:"vigneshkumar", title:"Test blog", description:"test description") {
createblogpost {
id
author
title
description
publishedDate
updatedAt
}
}
}
# Response
{
"data": {
"createBlog": {
"createblogpost": {
"id": "8",
"author": "vickykumar",
"title": "test create blog",
"description": "test blog description",
"publishedDate": "2020-03-03T06:56:12.902488+00:00"
"updatedAt": null
}
}
}
}Update a existing blog post based on blog ID,
----------------------------------------------------------mutation {
updateblog (blogId:7, author:"updated", title:"updated title", description:"updated desc") {
blogupdate {
id
author
title
description
publishedDate
updatedAt
}
}
}Create a New comment
----------------------------------------------------------mutation {
createcomment (author:"updated", comment:"test comment") {
createcommentpost {
id
comment
author {
id
}
}
}
}Delete a existing comment based on comment ID
----------------------------------------------------------mutation {
deletecomment(commentId:1) {
commentId
}
}