Knowledge Base updated: 2026-11-17
Strawberry knowledge base
Orientation
Strawberry is a Python GraphQL library. Python decorators and annotations define GraphQL types, which are converted into a graphql-core schema and executed through Schema.
Its core packages cover type definition, schema construction, operation execution, subscriptions, and batching. Framework integrations layer HTTP, ASGI, and WebSocket transport behavior over a shared schema.
Cross-cutting capabilities live in extensions, permissions, directives, federation, Relay, Pydantic integration, and developer tooling. Critical request state is carried through execution context, resolver context, DataLoader instances, and transport request/response objects.
flowchart TD
App[Application Python types] --> Types[Type definitions]
Types --> Schema[Schema construction]
Schema --> Core[graphql-core schema]
Client[GraphQL client] --> Transport[HTTP / ASGI transport]
Transport --> Execution[Operation execution]
Execution --> Schema
Execution --> Resolvers[Resolvers]
Resolvers --> Loader[DataLoader]
Execution --> Result[Execution result]
Schema --> Extensions[Extensions and permissions]
Schema --> Federation[Federation]
Schema --> Relay[Relay]
Types --> Pydantic[Pydantic integration]
Schema --> Tooling[CLI and code generation]
Transport --> Frameworks[Framework adapters]
Glossary
- Strawberry type: Python declaration annotated by Strawberry decorators and metadata for GraphQL schema conversion.
- Schema: The Strawberry object that owns the graphql-core schema and executes GraphQL operations.
- DataLoader: Request-scoped asynchronous batching and caching utility for resolver data access.
- GlobalID: Relay-compatible opaque identifier combining a GraphQL type name and node identifier.
- Subgraph: A federation-enabled GraphQL service composed with other services.
Codebase-wide invariants
- Public GraphQL types are declared through Strawberry metadata and decorators rather than raw graphql-core type construction; see
strawberry/types/**andstrawberry/schema/**. - Resolver annotations must be resolvable into Strawberry/GraphQL types before schema conversion; see strawberry/annotation.py and
strawberry/types/**. - Framework adapters delegate GraphQL request semantics to shared HTTP or ASGI base behavior; see
strawberry/http/**,strawberry/asgi/**, and strawberry/…/views.py. - Async batching is coordinated through
DataLoaderrather than implicit resolver batching; see strawberry/dataloader.py. - Federation and Relay extend normal schema/type behavior through dedicated packages; see
strawberry/federation/**andstrawberry/relay/**.