ScriptsJul 18, 2026·2 min read

Strawberry — Type-Annotated GraphQL Library for Python

A Python GraphQL library that leverages dataclasses and type annotations to define schemas with zero boilerplate.

Agent ready

Ready-to-run agent install

This asset can be installed after the agent chooses its runtime, checks the plan, and runs the matching command.

Native · 98/100Policy: allow
Agent surface
Any MCP/CLI agent
Kind
Skill
Install
Single
Trust
Trust: Established
Entrypoint
Strawberry GraphQL for Python
Direct install command
npx -y tokrepo@latest install 1d572c91-82e9-11f1-9bc6-00163e2b0d79 --target codex

Run after dry-run confirms the install plan.

Introduction

Strawberry is a modern Python GraphQL library built on type annotations and dataclasses. Instead of writing schema definitions in a separate DSL, you define your GraphQL types directly in Python using decorators and standard typing, getting full IDE autocompletion and type checking for free.

What Strawberry Does

  • Defines GraphQL schemas using Python type annotations and dataclasses
  • Generates schema SDL automatically from decorated Python classes
  • Integrates with Django, FastAPI, Flask, and ASGI frameworks
  • Supports subscriptions, federation, and file uploads
  • Provides a built-in GraphiQL IDE for development

Architecture Overview

Strawberry uses Python decorators to transform regular classes into GraphQL types at import time. A schema compiler inspects type annotations to build the GraphQL type system, resolvers, and validation rules. The execution layer delegates to graphql-core for query parsing and validation while adding async support and DataLoader integration.

Self-Hosting & Configuration

  • Install via pip: pip install strawberry-graphql[fastapi]
  • Add framework integration (Django, FastAPI, Flask, Starlette)
  • Configure via schema instantiation options (extensions, directives)
  • Enable debug mode with built-in GraphiQL at /graphql
  • Deploy as a standard ASGI/WSGI application

Key Features

  • Code-first schema definition with full IDE support
  • Native async/await support for resolvers
  • Built-in DataLoader pattern for N+1 query prevention
  • Apollo Federation support for distributed graphs
  • Pydantic integration for input validation

Comparison with Similar Tools

  • Graphene — Older Python GraphQL library; more verbose class-based API
  • Ariadne — Schema-first approach using SDL strings; Strawberry is code-first
  • tartiflette — Async-first with SDL; less community adoption
  • Apollo Server (JS) — Node.js equivalent; Strawberry brings similar DX to Python

FAQ

Q: Can I use Strawberry with Django? A: Yes. Install strawberry-graphql-django for model integration, permission handling, and pagination support.

Q: Does Strawberry support file uploads? A: Yes. It implements the GraphQL multipart request specification for file upload mutations.

Q: How does Strawberry handle authentication? A: Via context injection. Your framework middleware sets auth info on the request context, which resolvers access through the info parameter.

Q: Is Strawberry compatible with Apollo Federation? A: Yes. Decorate types with @strawberry.federation.type and configure entity resolvers to participate in a federated graph.

Sources

Discussion

Sign in to join the discussion.
No comments yet. Be the first to share your thoughts.

Related Assets