strawberry-graphql

Strawberry is a Python GraphQL library based on type annotations, defining schemas in a dataclasses style, with integrations for Django, FastAPI, Starlette, and more.

0.338.0
Published at
2d ago
4,724
Stars
27
Download
Synced at
2d ago

Latest release

0.338.0Oct 26, 2026, 12:30 PM
Downloads slow? Switch the source anytime above

README

Project Overview

Strawberry is a Python GraphQL library that builds APIs from type annotations: schemas are defined by classes decorated with @strawberry.type, in a style similar to dataclasses. It supports asyncio and many async frameworks, ships a dev server with a GraphiQL UI, and provides a mypy plugin for static checks of the GraphQL schema. Its code-first approach keeps API definitions and business logic in one place.

Item Value
Language Python
Type GraphQL library (code-first)
Integrations Django, FastAPI, Starlette, Flask and more
Async asyncio support
License MIT

Type annotations become the schema, with mypy watching over correctness.

Key Features

  • Annotation-driven schema: declare GraphQL types and fields with plain classes and type hints
  • Async support: asyncio-based resolvers for modern async frameworks
  • Framework integrations: ready-made views for Django, FastAPI, Starlette, Flask, and Quart
  • Dev server: strawberry dev starts a GraphiQL-enabled debug server in one command
  • mypy plugin: static type checking of the schema to catch issues early
  • Data loading: works with dataloaders to cut duplicate queries
  • Subscriptions: supports GraphQL subscriptions for real-time pushes

Target Audience

  • Python backend developers
  • Users looking for an alternative to Ariadne or graphene
  • FastAPI and async framework users
  • Teams that value type checking and IDE hints

Quick Start

  1. Install the full package with CLI: pip install 'strawberry-graphql[cli]'
  2. Create app.py defining the schema
import strawberry

@strawberry.type
class User:
    name: str
    age: int

@strawberry.type
class Query:
    @strawberry.field
    def user(self) -> User:
        return User(name='Patrick', age=100)

schema = strawberry.Schema(query=Query)
  1. Start the dev server: strawberry dev app
  2. Open http://0.0.0.0:8000/graphql and test in GraphiQL

Core Advantages

  • Code as documentation: schema and business code share one source, no drift
  • Type-check friendly: the mypy plugin brings GraphQL types into static analysis
  • Async first: native asyncio support to unlock async performance
  • Broad integrations: existing integrations for mainstream Python web frameworks

System Requirements

Item Requirement
Language Python 3
OS Linux, macOS, Windows
Tooling pip to install, uv for development

Notes

  • Fast-moving releases: features land frequently, review the changelog before upgrading
  • Integrations are separate: the Django integration requires installing strawberry-graphql-django

Release history

Sort