Skip to content
Alexis ROLLAND edited this page Jan 31, 2018 · 67 revisions

Flask Graphene SQLAlchemy Tutorial

Introduction

Welcome to this tutorial. Its objective is to describe step by step how to create a GraphQL API using Python and more specifically the following packages:

The API will expose data coming from an SQLite database stored locally on your machine and the end result will follow the logical architecture described in the schema below.

Architecture

Workstation set-up

First you need to install the third party Python packages mentioned above.

$ cd flask-graphene-sqlalchemy
$ pip3 install -r requirements.txt

Create the database

We will create the database using SQLAlchemy and according to the data model below. This database will contain some Star Wars data stored in 2 different tables (source: The Star Wars API):

  • Planet: List of planets appearing in Star Wars movies
  • People: List of people appearing in Star Wars movies

Note there is a relationship between planets and peoples as one planet is the homeworld of one person in the people table. It is a "one to many" relationship (one planet, many people).

Data model