This project is an example of GraphQL and Django, using graphene-django. You can read the post explaining this project here.
First, download the graphql-django-example project files to your workspace:
$ git clone https://github.com/joaorafaelm/graphql-django-example;
$ cd graphql-django-example;
We're going to use a virtual environment to easily manage dependencies for this demo. If you're not yet familiar with virtual environments for Python, using virtualenv, take a moment to learn about them. If you're already familiar with the concept, create one for the project:
$ virtualenv venv;
$ source venv/bin/activate;
The requirements.txt file specifies the versions of django, and graphene-django, I'd like you to install. To do this, installing them into your virtual environment, type:
$ pip install -r requirements.txt
./manage.py migrate
./manage.py loaddata books.json
If you wish to add more data, run ./manage.py createsuperuser
, and you can use the admin interface, at /admin
, after the runserver
step below.
./manage.py runserver
Visit the link returned by runserver
and visit the graphql
route. This is likely to look like "http://127.0.0.1:8000/graphql."