This project is a template project to scaffold or create the initial structure of your project
using django, graphene-django, djangorestframework and django-filter. This project is helps
you to build a graphql API OpenCRUD compliance.`
To read more about OpenCRUD please go to: https://www.opencrud.org/
PROJECT STRUCTURE
| File Name | Description |
|---|---|
├── config/ |
This folder contains the source files for the config. |
├── requirements/ |
This folder contains the source files for the requirements. |
.gitignore |
Git ignore config file |
manage.py |
|
requirements.develop |
Requirement file for development mode. |
requirements.production |
Requirement file for production mode. |
requirements.staging |
Requirement file for staging mode. |
requirements.testing |
Requirement file for testing mode. |
run.py |
Entrypoint for production mode. |
tox.ini |
Config file for linting, testing, coverage and ohter things. |
- Python 3.9: https://www.python.org/downloads/
- Git for Windows (only for Windows): https://git-scm.com/downloads
If you are using Windows, use git bash to run these commands.
Creating the project folder
mkdir awesome-graphql-api && cd awesome-graphql-apiCreating the virtual environment
python -m venv venvActivating the virtual environment
source venv/bin/activateFor Windows only
. venv/Scripts/activateDeactivating the virtual environment
deactivateUpdating pip and installing pip-tools
python -m pip install --upgrade pip && pip install pip-toolsFor development
pip-compile -r requirements/develop.in -o requirements.developFor production
pip-compile -r requirements/production.in -o requirements.productionFor staging
pip-compile -r requirements/staging.in -o requirements.stagingFor testing
pip-compile -r requirements/testing.in -o requirements.testingFor development
pip install -r requirements.developFor production
pip install -r requirements.productionFor staging
pip install -r requirements.stagingFor testing
pip install -r requirements.testingdjango-admin startproject --template https://github.com/danilobrinu/django-graphql-project-template/archive/master.zip <awesome-project> .Example:
django-admin startproject --template https://github.com/danilobrinu/django-graphql-project-template/archive/master.zip my-graphql-api
django-admin startapp --template https://github.com/danilobrinu/django-graphql-app-template/archive/master.zip <awesome-app>Example: python manage.py --template https://github.com/danilobrinu/django-graphql-app-template/archive/master.zip api_v1
Note: to read more about scaffoling an app, please go to: https://github.com/danilobrinu/django-graphql-app-template
To scaffold a domain app you need to go to inside of the domain folder part of an app. Only run this
this command inside of the your <awesome-app>/domain folder. For instance: api_v1/domain
django-admin startapp --template https://github.com/danilobrinu/django-graphql-app-domain-template/archive/master.zip <awesome-app-domain>Example: django-admin startapp --template https://github.com/danilobrinu/django-graphql-app-domain-template/archive/master.zip post
Note: to read more about scaffolding a domain app, please go to: https://github.com/danilobrinu/django-graphql-domain-app-template.
For development
python manage.py runserverFor production
python run.py
Endpoint URL: http://<domain>/<path-to-your-graphql-endpoint>
For development: The domain is localhost:8000 and the path to your graphql is graphql/v1.
Open the GraphQL Playground with http://localhost:8000/graphql/v1
For production: The domain is awesome.graphql.io and the path to your graphql is graphql/v1.
Open the GraphQL Playground with http:///awesome.graphql.io/graphql/v1
Note: change
awesome.graphql.ioto your endpoint for production.