Using GraphQL with Strawberry, FastAPI, and Next.js

This page summarizes the projects mentioned and recommended in the original post on

Our great sponsors
  • InfluxDB - Collect and Analyze Billions of Data Points in Real Time
  • Sonar - Write Clean Python Code. Always.
  • Mergify - Tired of breaking your main and manually rebasing outdated pull requests?
  • You can find all the code for this article on my GitHub. In the future, I might create a full project to show you amore concrete example of how you can make use of the generated code in your apps. In the meantime, you can take a look at this repo, which was inspiration for this article. Jokull was probably the first person to publicly host a project combining all of these different tools. Thanks, Jokull!

  • python-ts-graphql-demo

    Demo project to demonstrate how an asyncio Python project with SQLAlchemy and Strawberry can have a great typed DX on the frontend via codegen and TypeScript React hooks.

    This post is inspired by this GitHub repo.

  • InfluxDB

    Collect and Analyze Billions of Data Points in Real Time. Manage all types of time series data in a single, purpose-built database. Run at any scale in any environment in the cloud, on-premises, or at the edge.

  • aiosqlite

    asyncio bridge to the standard sqlite3 module

    Aiosqlite — This provides async support for SQLite

  • graphql-code-generator

    A tool for generating code based on a GraphQL schema and GraphQL operations (query/mutation/subscription), with flexible support for custom plugins.

    There has been discussion to make graphql-codegen generate all mutations and queries by introspecting our online GraphQL API, but so far it is not possible to do that using only graphql-codegen. There do exist tools that allow you to do that, but I am not going to use them in this article. You can explore them on your own.

  • uvicorn

    An ASGI web server, for Python. 🦄

    Uvicorn — This is an ASGI web server that will serve our FastAPI application in production

  • SQLAlchemy

    The Database Toolkit for Python

    SQLAlchemy — This is our ORM for working with SQLite DB

  • strawberry

    A GraphQL library for Python that leverages type annotations 🍓

    We will be focusing on one such library called Strawberry. It is relatively new and requires Python 3.7+ because it makes use of Python features that weren't available in earlier versions of the language. It makes heavy use of dataclasses and is fully typed using mypy.

  • Sonar

    Write Clean Python Code. Always.. Sonar helps you commit clean code every time. With over 225 unique rules to find Python bugs, code smells & vulnerabilities, Sonar finds the issues while you focus on the work.

  • Graphene

    GraphQL framework for Python

    There are multiple Python-based GraphQL libraries and they all vary slightly from each other. For the longest time, Graphene was a natural choice as it was the oldest and was used in production at different companies, but now other newer libraries have also started gaining some traction.

  • fastapi

    FastAPI framework, high performance, easy to learn, fast to code, ready for production

    FastAPI — This is our web framework for serving our Strawberry-based GraphQL API

NOTE: The number of mentions on this list indicates mentions on common posts plus user suggested alternatives. Hence, a higher number means a more popular project.

Suggest a related project

Related posts