https://github.com/moesif/moesif-graphene-django-example
Example GraphQL API using Django and Graphene
https://github.com/moesif/moesif-graphene-django-example
Last synced: 6 months ago
JSON representation
Example GraphQL API using Django and Graphene
- Host: GitHub
- URL: https://github.com/moesif/moesif-graphene-django-example
- Owner: Moesif
- Created: 2018-03-10T01:46:07.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2023-07-16T17:08:20.000Z (about 2 years ago)
- Last Synced: 2025-04-01T20:51:32.351Z (6 months ago)
- Language: Python
- Size: 19.5 KB
- Stars: 14
- Watchers: 8
- Forks: 9
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
### Graphene Django Project
This example project demonstrate an integration between Graphene and Django.
You'll build an Event Model to access event objects through GraphQL.First you'll need to get the source of the project. Do this by cloning the repository:
```bash
# Get the project code
git clone https://github.com/Moesif/moesif-graphene-django-example.git
```*NOTE: While working with Python, we would recommend to use virtual environment
to keep all the project's dependencies isolated from other projects.*##### Create your local environment
```bash
conda create -n graphql python=3.6 anaconda # Create the environment
source activate graphql # Activate the environment
```##### Install dependencies
```python
pip install -r requirements.txt
```##### Create database table
```bash
python manage.py makemigrations
python manage.py migrate
```##### Create mock data
```bash
$ python manage.py shell
>>> from events.models import Event
>>> Event.objects.create(name='API Analytics', url='https://www.moesif.com/')
>>> Event.objects.create(name='Trove Marketplace', url='https://www.trove.com/')
```##### Start the application
```bash
python manage.py runserver
```##### Query data through GraphQL
Go to [localhost](http://localhost:8000/graphql/) on [Insomnia](https://insomnia.rest/download/#mac)
or your favorite browser to Create/Search/Filter data through GraphQL. More detail on how to write your first
query and mutation could be found [here](https://www.moesif.com/blog/technical/graphql/Getting-Started-with-Python-GraphQL-Part1/).