Skip to content
This repository has been archived by the owner on Nov 3, 2022. It is now read-only.

A GraphQL, Django server boilerplate built with Graphene

License

Notifications You must be signed in to change notification settings

ngshiheng/django-graphene-starter

Repository files navigation

GraphQL Graphene Starter


A GraphQL server boilerplate, built in Django.

CI/CD codecov License: MIT

A GraphQL, Django server boilerplate built with Graphene.

Tech Stacks

Features

  • Reporters -> Articles dataloader query
  • Articles -> Reporter dataloader query
  • Authentication and permission control
  • Hosted on Heroku
  • Sentry integration
  • Tested with Pytest
  • Basic rate limiting
  • Renovate bot
  • Caching

Getting Started

Installing Dependencies

pipenv sync --dev

How to Use

Optional: Docker

To run this project with docker:

docker-compose up -d --build

Run Development Server Locally

# Database migration
pipenv run python3 django_graphene_starter/manage.py migrate

# Run GraphQL server at localhost:8000 by default
pipenv run python3 django_graphene_starter/manage.py runserver

# Run GraphQL server with gunicorn
gunicorn --chdir django_graphene_starter django_graphene_starter.wsgi

Run Shell Locally

pipenv run python3 django_graphene_starter/manage.py shell_plus

List Model Info

python3 django_graphene_starter/manage.py list_model_info --field-class

Queries and Mutation

Run in Insomnia}

Read more about using Insomnia for API development here.

Generating Fixtures

mixer is used to generate fixtures for this project.

# To generate fixtures
python3 django_graphene_starter/manage.py generate_fixtures -r 1000 -a 10 -p 10

# To delete all data
python django_graphene_starter/manage.py flush

Running pytest

pipenv run pytest django_graphene_starter

References

Dataloader

Sentry


Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change

Setup Pre-commit Hooks

Before you begin your development work, make sure you have installed pre-commit hooks.

Some example useful invocations:

  • pre-commit install: Default invocation. Installs the pre-commit script alongside any existing git hooks.
  • pre-commit install --install-hooks --overwrite: Idempotently replaces existing git hook scripts with pre-commit, and also installs hook environments

Steps

  1. Fork this
  2. Create your feature branch (git checkout -b feature/fooBar)
  3. Commit your changes (git commit -am 'Add some fooBar')
  4. Push to the branch (git push origin feature/fooBar)
  5. Create a new Pull Request