Skip to content

ocni-dtu/strawberry_async_template

Repository files navigation

Strawberry Template

This repo is a template for setting up a project as a GraphQL API, using the async capabilities of FastAPI and Strawberry.

For the database connection we use SQLModel as an ORM and PostgreSQL as the database.

This template is for an async setup. If you wish to create a sync API please refer to this template

The deployment is done with Kubernetes, Helm and Skaffold.

Folder Structure

alembic/
    # Contains migrations
graphql/
    # Contains graphql schema for the gateway
helm/
    # helm chart for deployment
src/
    # source code
    core/
        # code related to FastAPI/webserver
    exceptions/
        # custom exceptions
    graphql_types/
        # GraphQL types for Strawberry
    routes/
        # api routes. We only have one /api/graphql
    schema/
        # graphql schema definitions
tests/
    # test code 

Get Started

After cloning this template, please replace all instances of ASYNC_STRAWBERRY in the files, with your own project name.

To get started please make sure that the following pieces of software are installed on your machine.

Software dependencies

Windows

Linux

Install dependencies

# Install packages
pipenv install --dev

# Install pre-commit hooks
pre-commit install

Start dev server

# Start Minikube to run a local Kubernetes cluster
minikube start
# Run Skaffold
skaffold dev

Run tests locally

pytest tests/

Make migration Skaffold should be running!

./local_migration.sh

Export GraphQL schema

./export_schema.sh

Access API

When the containers are running (see steps below) the API can be accessed at http://localhost:8000/api/graphql

About

Async Strawberry, FastAPI, SQLModel, Postgres Template

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published