Our great sponsors
-
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 — 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 — This is an ASGI web server that will serve our FastAPI application in production
-
SQLAlchemy — This is our ORM for working with SQLite DB
-
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.
-
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 — This is our web framework for serving our Strawberry-based GraphQL API
Related posts
- Strawberry Django Plus: Enchanted Strawberry GraphQL integration with Django
- Getting started with GraphQL in Python with FastAPI and Ariadne
- Ask HN: What would you use to build a mostly CRUD back end today?
- Strawberry: A Python Library for GraphQL
- How to Dockerize and Deploy a Fast API Application to Kubernetes Cluster