Using GraphQL with Strawberry, FastAPI, and Next.js

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

Our great sponsors
  • Zigi - Delete the most useless function ever: context switching.
  • Scout APM - Truly a developer’s best friend
  • Sonar - Write Clean Python Code. Always.
  • InfluxDB - Build time-series-based applications quickly and at scale.
  • 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.

  • Zigi

    Delete the most useless function ever: context switching.. Zigi monitors Jira and GitHub updates, pings you when PRs need approval and lets you take fast actions - all directly from Slack! Plus it reduces cycle time by up to 75%.

  • 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.

  • Scout APM

    Truly a developer’s best friend. Scout APM is great for developers who want to find and fix performance issues in their applications. With Scout, we'll take care of the bugs so you can focus on building great things 🚀.

  • 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