/django-graphql-trial

GraphQL API with Django

Primary LanguagePython

Django GraphQL Trial

Application to test out using GraphQL in Django.

Built with Python3.

Requirements

  • Python 3.7
  • Django 2.2

Installation

Clone Project

git clone https://github.com/taiyeoguns/django-graphql-trial.git

Get Pipenv

If not already installed, install Pipenv

Install Requirements

Create virtual environment and install the application requirements:

pipenv install

Thereafter activate environment by running:

pipenv shell

To deactivate environment, run:

exit

Add details in .env file

Create .env file from example file and maintain necessary details in it.

cp .env.example .env

Run migrations

Create tables in the database:

python manage.py migrate

Seed database

To populate database with sample data, run:

python manage.py seed

Run the application

Start the application by running:

python manage.py runserver

Open a browser and navigate to http://localhost:8000/graphql

Sample Request

In Graphiql, enter the following sample requests:

query {
  departments {
    id
    name
    createdAt
  }
}
query {
  employees {
    id
    firstName
    lastName
    department {
      id
      name
    }
    createdAt
  }
}

Tests

In command prompt, run:

pytest -v

Further Information