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-api
Creating the virtual environment
python -m venv venv
Activating the virtual environment
source venv/bin/activate
For Windows only
. venv/Scripts/activate
Deactivating the virtual environment
deactivate
Updating pip and installing pip-tools
python -m pip install --upgrade pip && pip install pip-tools
For development
pip-compile -r requirements/develop.in -o requirements.develop
For production
pip-compile -r requirements/production.in -o requirements.production
For staging
pip-compile -r requirements/staging.in -o requirements.staging
For testing
pip-compile -r requirements/testing.in -o requirements.testing
For development
pip install -r requirements.develop
For production
pip install -r requirements.production
For staging
pip install -r requirements.staging
For testing
pip install -r requirements.testing
django-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 runserver
For 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.io
to your endpoint for production.