Esta página se muestra en inglés. Una traducción al español está en curso.
ScriptsJul 18, 2026·2 min de lectura

Strawberry — Type-Annotated GraphQL Library for Python

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

Listo para agents

Instalación lista para agent

Este activo puede instalarse después de elegir el runtime, revisar el plan y ejecutar el comando correspondiente.

Native · 98/100Política: permitir
Superficie agent
Cualquier agent MCP/CLI
Tipo
Skill
Instalación
Single
Confianza
Confianza: Established
Entrada
Strawberry GraphQL for Python
Comando de instalación directa
npx -y tokrepo@latest install 1d572c91-82e9-11f1-9bc6-00163e2b0d79 --target codex

Ejecutar después de confirmar el plan con dry-run.

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

Discusión

Inicia sesión para unirte a la discusión.
Aún no hay comentarios. Sé el primero en compartir tus ideas.

Activos relacionados