Skip to content

ProjectCheshire/graphql-python-starter

GraphQL-Python Starter

Boston Python User Group collaborative project

Table of Contents

Description

  • Welcome! The purpose of this repository is to serve as an introduction to GraphQL using Python.
  • This repository began at a Boston Python User Group meeting on May 20, 2019.
  • We are using Flask as a simple web server.
  • The GraphQL features are implemented using Graphene Python.
  • This example does not yet cover subscriptions, which will be covered at a later date.

Getting started

Install and run locally

Install dependencies

From the command line:

brew install git node python pipenv postgresql

Clone or fork repository

cd path/where/you/want/the/repo
git clone git@github.com:ProjectCheshire/graphql-python-starter.git

Install virtual environment

In repository directory:

pipenv install --dev

Install pre-commit hooks

pipenv shell
graphql-python-starter-hash ❯ pre-commit install

Set up database

graphql-python-starter-hash ❯ python manage.py db init
graphql-python-starter-hash ❯ python manage.py db upgrade
graphql-python-starter-hash ❯ python manage.py db migrate
graphql-python-starter-hash ❯ python seed_db.py

If you run into errors, try:

  • Deleting the migrations directory: If you receive Error: Directory migrations already exists, delete the migrations/ directory and re-run python manage.py db init.

  • Delete the files inside /migrations/versions, but don't delete the /versions directory itself.

  • Re-creating the database:

    graphql-python-starter-hash ❯ psql postgres
    psql (version)
    Type "help" for help.
    user=$ DROP DATABASE starwars;
    DROP DATABASE
    user=$ CREATE DATABASE starwars;
    CREATE DATABASE
    user=$ \q
    
Verify database creation
graphql-python-starter-hash ❯ psql -d starwars
# psql (version)
# Type "help" for help.

starwars=$ \dt
               List of relations
 Schema |      Name       | Type  |    Owner
--------+-----------------+-------+-------------
 public | alembic_version | table | user
 public | factions        | table | user
 public | heroes          | table | user
 public | memberships     | table | user
 public | planets         | table | user
(5 rows)

starwars=# \q

Client Code

Make sure you have Node downloaded

Command-line instructions

cd client
# Install all dependencies
npm i
# Create and run js bundle
npm run start

Install and run with Docker Compose

Coming soon!

Further details and guidelines for contributing

See the contributing guidelines for more detailed instructions.

Code of conduct

Please abide by the guidelines in the Code of Conduct.

About

GraphQL-Python Starter

Resources

License

Code of conduct

Contributing

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 5