A Django project that implements a simple news application with GraphQL support. This project demonstrates the use of Django and GraphQL for building APIs.
- User authentication with JWT
- Create and manage links
- Query users and links with GraphQL
- Python 3.6 or later
- Django 2.1.4
- Graphene-Django 2.2.0
- GraphQL-JWT
-
Clone the Repository
git clone https://github.com/yourusername/your-repo.git cd your-repo
-
Set Up a Virtual Environment
python3 -m venv venv source venv/bin/activate # On Windows use `venv\Scripts\activate`
-
Install Dependencies
pip install -r requirements.txt
-
Apply Migrations
python manage.py migrate
-
Create a Superuser (Optional)
python manage.py createsuperuser
-
Run the Development Server
python manage.py runserver
Open your browser and navigate to
http://127.0.0.1:8000/graphql/
to access the GraphQL API.
-
GraphQL Endpoints
-
Query Links
query { links { id url description } }
-
Create a Link
mutation { createLink(url: "https://example.com", description: "Example Link") { id url description } }
-
-
User Authentication
-
Obtain JSON Web Token
mutation { tokenAuth(username: "yourusername", password: "yourpassword") { token } }
-
Verify Token
mutation { verifyToken(token: "yourjwt") { payload } }
-
Refresh Token
mutation { refreshToken(token: "yourjwt") { token } }
-
This project is licensed under the MIT License - see the LICENSE file for details.