ionescu77 / django-blog-app-hasura

Simple blog application using django and hasura

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Simple blog application using Django

https://www.freecodecamp.org/news/how-to-get-instant-graphql-apis-on-your-existing-django-application-c8fcfdb945aa/

Setup

pip install -r requirements.txt

Configure postgres

Install postgres using docker or from the source

Update settings.py with the correct postgres connection values.

Apply migrations

Run python manage.py migrate to create appropriate tables in the database.

Testing

Fetch all articles

  curl http://localhost:8000/articles -H "Authorization: Bearer 70kc8b75ca68amj3xwrayqvy9j46yzr" -H 'Content-Type: application/json'
[
  {
    "title": "Update rows using postgres",
    "description": "Update rows using postgres",
    "author_id": 2,
    "id": 2
  }
]

Fetch articles owned by the specific author

  curl  http://localhost:8000/author/articles -H "Authorization: Bearer 70kc8b75ca68amj3xwrayqvy9j46yzrf" -H 'Content-Type: application/json'
[
  {
    "title": "Insert rows using postgres",
    "description": "This blog post will take you through the steps which needs to be followed to insert rows using postgres",                       
    "author_id": 2,
    "id": 1
  },
  {
    "title": "Update rows using postgres",
    "description": "Update rows using postgres",
    "author_id": 2,
    "id": 2
  }
]

About

Simple blog application using django and hasura


Languages

Language:Python 100.0%