NewYour coding agent can read the release notes before it upgrades.Set up the MCP server →
PyPI, #1553 most downloaded on PyPI
A library for creating GraphQL APIs
Latest stable
0.341.2
Last release 15 days ago
07 Nov 2026
Ships fairly regularly
a new release about every 1 weeks
Nearly every release is documented
notes for 60 of the last 60 stable releases
Nothing withdrawn
no release was ever pulled
8 years old
1155 releases · first in 2019
Drag across the ruler to compare, or tap a release to open it.
Add on_executing_* hooks to extensions to allow you to override the execution phase of a GraphQL operation.
Add on_executing_* hooks to extensions to allow you to override the execution phase of a GraphQL operation.
Contributed by Jonathan Kim PR #1400
Nothing published for this version
Nothing published for this version
Nothing published for this version
Your coding agent can read these notes before it upgrades. Set up the MCP server →
Nothing published for this version
Nothing published for this version
Nothing published for this version
This release fixes an issue with schema directives not being printed correctly.
This release fixes an issue with schema directives not being printed correctly.
Contributed by Patrick Arminio PR #1376
This release introduces initial support for schema directives and updates the federation support to use that.
This release introduces initial support for schema directives and updates the federation support to use that.
Full support will be implemented in future releases.
Contributed by Patrick Arminio PR #815
Field definition uses output of default_factory as the GraphQL default_value .
Field definition uses output of default_factory as the GraphQL default_value .
a_field: list[ str ] = strawberry.field( default_factory = list )
aField : [ String !]! = []
Contributed by A. Coady PR #1371
This release fixed the typing support for Pyright.
This release fixed the typing support for Pyright.
Contributed by Patrick Arminio PR #1363
This release adds an extra dependency for FastAPI to prevent it being downloaded even when not needed.
This release adds an extra dependency for FastAPI to prevent it being downloaded even when not needed.
To install Strawberry with FastAPI support you can do:
pip install 'strawberry-graphql[fastapi]'
Contributed by Patrick Arminio PR #1366
This release fixes the merge_types type signature.
This release fixes the merge_types type signature.
Contributed by Guillaume Andreu Sabater PR #1348
This release adds support for FastAPI integration using APIRouter.
This release adds support for FastAPI integration using APIRouter.
import strawberry
from fastapi import FastAPI
from strawberry.fastapi import GraphQLRouter
@strawberry.type
class Query :
@strawberry.field
def hello ( self ) -> str :
return "Hello World"
schema = strawberry.Schema(Query)
graphql_app = GraphQLRouter(schema)
app = FastAPI()
app.include_router(graphql_app, prefix = "/graphql" )
Contributed by Jiří Bireš PR #1291
Improve help texts for CLI to work better on ZSH.
Improve help texts for CLI to work better on ZSH.
Contributed by Magnus Markling PR #1360
Errors encountered in subscriptions will now be logged to the strawberry.execution logger as errors encountered in Queries and Mutations are. <3
Errors encountered in subscriptions will now be logged to the strawberry.execution logger as errors encountered in Queries and Mutations are. <3
Contributed by Michael Ossareh PR #1316
Add logic to convert arguments of type LazyType.
Add logic to convert arguments of type LazyType.
Contributed by Luke Murray PR #1350
This release fixes a bug where passing scalars in the scalar_overrides parameter wasn’t being applied consistently.
This release fixes a bug where passing scalars in the scalar_overrides parameter wasn’t being applied consistently.
Contributed by Jonathan Kim PR #1212
Pydantic fields’ description are now copied to the GraphQL schema
Pydantic fields’ description are now copied to the GraphQL schema
import pydantic
import strawberry
class UserModel ( pydantic . BaseModel ):
age: str = pydantic.Field(..., description = "Description" )
@strawberry.experimental.pydantic.type (UserModel)
class User :
age: strawberry.auto
type User {
"""Description"""
age: String!
}
Contributed by Guillaume Andreu Sabater PR #1332
We now run our tests against Windows during CI!
We now run our tests against Windows during CI!
Contributed by Michael Ossareh PR #1321
Add a shortcut to merge queries, mutations. E.g.:
Add a shortcut to merge queries, mutations. E.g.:
import strawberry
from strawberry.tools import merge_types
@strawberry.type
class QueryA : ...
@strawberry.type
class QueryB : ...
ComboQuery = merge_types( "ComboQuery" , (QueryB, QueryA))
schema = strawberry.Schema( query =ComboQuery)
Contributed by Alexandru Mărășteanu PR #1273
Makes the GraphQLSchema instance accessible from resolvers via the info parameter.
Makes the GraphQLSchema instance accessible from resolvers via the info parameter.
Contributed by Aryan Iyappan PR #1311
Fix bug where errors thrown in the on_parse_* extension hooks were being swallowed instead of being propagated.
Fix bug where errors thrown in the on_parse_* extension hooks were being swallowed instead of being propagated.
Contributed by Jonathan Kim PR #1324
Adds support for the auto type annotation described in #1192 to the Pydantic integration, which allows a user to define the list of fields without hav
Adds support for the auto type annotation described in #1192 to the Pydantic integration, which allows a user to define the list of fields without having to re-specify the type themselves. This gives better editor and type checker support. If you want to expose every field you can instead pass all_fields=True to the decorators and leave the body empty.
import pydantic
import strawberry
from strawberry.experimental.pydantic import auto
class User ( pydantic . BaseModel ):
age: int
password: str
@strawberry.experimental.pydantic.type (User)
class UserType :
age: auto
password: auto
Contributed by Matt Allen PR #1280
Nothing published for this version
This release adds a safety check on strawberry.type , strawberry.input and strawberry.interface decorators. When you try to use them with an object th
This release adds a safety check on strawberry.type , strawberry.input and strawberry.interface decorators. When you try to use them with an object that is not a class, you will get a nice error message: strawberry.type can only be used with classes
Contributed by dependabot PR #1278
Add Starlette to the integrations section on the documentation.
Add Starlette to the integrations section on the documentation.
Contributed by Marcelo Trylesinski PR #1287
This release add support for the upcoming python 3.10 and it adds support for the new union syntax, allowing to declare unions like this:
This release add support for the upcoming python 3.10 and it adds support for the new union syntax, allowing to declare unions like this:
import strawberry
@strawberry.type
class User :
name: str
@strawberry.type
class Error :
code: str
@strawberry.type
class Query :
find_user: User | Error
Contributed by Patrick Arminio PR #719
This release adds support for the graphql-transport-ws GraphQL over WebSocket protocol. Previously Strawberry only supported the legacy graphql-ws pro
This release adds support for the graphql-transport-ws GraphQL over WebSocket protocol. Previously Strawberry only supported the legacy graphql-ws protocol.
Developers can decide which protocols they want to accept. The following example shows how to do so using the ASGI integration. By default, both protocols are accepted. Take a look at our GraphQL subscription documentation to learn more.
from strawberry.asgi import GraphQL
from strawberry.subscriptions import GRAPHQL_TRANSPORT_WS_PROTOCOL
from api.schema import schema
app = GraphQL(schema, subscription_protocols =[GRAPHQL_TRANSPORT_WS_PROTOCOL])
Contributed by Jonathan Ehwald PR #1256
Nests the resolver under the correct span; prior to this change your span would have looked something like:
Nests the resolver under the correct span; prior to this change your span would have looked something like:
GraphQL Query
GraphQL Parsing
GraphQL Validation
my_resolver
my_span_of_interest #1
my_sub_span_of_interest #2
After this change you’ll have:
GraphQL Query
GraphQL Parsing
GraphQL Validation
GraphQL Resolving: my_resolver
my_span_of_interest #1
my_sub_span_of_interest #2
Contributed by Michael Ossareh PR #1281
Enhances strawberry.extensions.tracing.opentelemetry to include spans for the Parsing and Validation phases of request handling. These occur before yo
Enhances strawberry.extensions.tracing.opentelemetry to include spans for the Parsing and Validation phases of request handling. These occur before your resovler is called, so now you can see how much time those phases take up!
Contributed by Michael Ossareh PR #1274
Fix extensions argument type definition on strawberry.Schema
Fix extensions argument type definition on strawberry.Schema
Contributed by Guillaume Andreu Sabater PR #1276
This release introduces some brand new extensions to help improve the performance of your GraphQL server:
This release introduces some brand new extensions to help improve the performance of your GraphQL server:
ParserCache - Cache the parsing of a query in memory
ValidationCache - Cache the validation step of execution
For complicated queries these 2 extensions can improve performance by over 50%!
Example:
import strawberry
from strawberry.extensions import ParserCache, ValidationCache
schema = strawberry.Schema(
Query,
extensions =[
ParserCache(),
ValidationCache(),
],
)
This release also removes the validate_queries and validation_rules parameters on the schema.execute* methods in favour of using the DisableValidation and AddValidationRule extensions.
Contributed by Jonathan Kim PR #1196
This release adds support for Sanic v21
This release adds support for Sanic v21
Contributed by dependabot PR #1105
Fixes returning “500 Internal Server Error” responses to requests with malformed json when running with ASGI integration.
Fixes returning “500 Internal Server Error” responses to requests with malformed json when running with ASGI integration.
Contributed by Olesia Grydzhuk PR #1260
This release adds python_name to the Info type.
This release adds python_name to the Info type.
Contributed by Joe Freeman PR #1257
Fix the Pydantic conversion method for Enum values, and add a mechanism to specify an interface type when converting from Pydantic. The Pydantic inter
Fix the Pydantic conversion method for Enum values, and add a mechanism to specify an interface type when converting from Pydantic. The Pydantic interface is really a base dataclass for the subclasses to extend. When you do the conversion, you have to use strawberry.experimental.pydantic.interface to let us know that this type is an interface. You also have to use your converted interface type as the base class for the sub types as normal.
Contributed by Matt Allen PR #1241
Fixes a bug with the selected_fields property on info when an operation variable is not defined.
Fixes a bug with the selected_fields property on info when an operation variable is not defined.
Issue #1248 .
Contributed by Jonathan Kim PR #1249
Fix issues ( #1158 and #1104 ) where Generics using LazyTypes and Enums would not be properly resolved
Fix issues ( #1158 and #1104 ) where Generics using LazyTypes and Enums would not be properly resolved
These now function as expected:
T = TypeVar( "T" )
@strawberry.enum
class VehicleMake ( Enum ):
FORD = "ford"
TOYOTA = "toyota"
HONDA = "honda"
@strawberry.type
class GenericForEnum (Generic[T]):
generic_slot: T
@strawberry.type
class SomeType :
field: GenericForEnum[VehicleMake]
another_file.py
@strawberry.type
class TypeFromAnotherFile :
something: bool
this_file.py
T = TypeVar( "T" )
@strawberry.type
class GenericType (Generic[T]):
item: T
@strawberry.type
class RealType :
lazy: GenericType[LazyType[ "TypeFromAnotherFile" , "another_file.py" ]]
Contributed by ignormies PR #1235
This release adds fragment and input variable information to the selected_fields attribute on the Info object.
This release adds fragment and input variable information to the selected_fields attribute on the Info object.
Contributed by Jonathan Kim PR #1213
Fixes a bug in the Pydantic conversion code around Union values.
Fixes a bug in the Pydantic conversion code around Union values.
Contributed by Matt Allen PR #1231
Fixes a bug in the export-schema command around the handling of local modules.
Fixes a bug in the export-schema command around the handling of local modules.
Contributed by Matt Allen PR #1233
Fixes a bug in the Pydantic conversion code around complex Optional values.
Fixes a bug in the Pydantic conversion code around complex Optional values.
Contributed by Matt Allen PR #1229
This release adds a new exception called InvalidFieldArgument which is raised when a Union or Interface is used as an argument type. For example this
This release adds a new exception called InvalidFieldArgument which is raised when a Union or Interface is used as an argument type. For example this will raise an exception:
import strawberry
@strawberry.type
class Noun :
text: str
@strawberry.type
class Verb :
text: str
Word = strawberry.union( "Word" , types =(Noun, Verb))
@strawberry.field
def add_word ( word : Word) -> bool : ...
Contributed by Mohammad Hossein Yazdani PR #1222
Fix type resolution when inheriting from types from another module using deferred annotations.
Fix type resolution when inheriting from types from another module using deferred annotations.
Contributed by Daniel Bowring PR #1010
This release adds support for Pyright and Pylance, improving the integration with Visual Studio Code!
This release adds support for Pyright and Pylance, improving the integration with Visual Studio Code!
Contributed by Patrick Arminio PR #922
Change the version constraint of opentelemetry-sdk and opentelemetry-api to <2
Change the version constraint of opentelemetry-sdk and opentelemetry-api to <2
Contributed by Michael Ossareh PR #1226
This release adds support for enabling subscriptions in GraphiQL on Django by setting a flag subscriptions_enabled on the BaseView class.
This release adds support for enabling subscriptions in GraphiQL on Django by setting a flag subscriptions_enabled on the BaseView class.
from strawberry.django.views import AsyncGraphQLView
from .schema import schema
urlpatterns = [
path(
"graphql" ,
AsyncGraphQLView.as_view(
schema =schema, graphiql = True , subscriptions_enabled = True
),
)
]
Contributed by lijok PR #1215
This release fixes an issue with the MyPy plugin that prevented using TextChoices from django in strawberry.enum .
This release fixes an issue with the MyPy plugin that prevented using TextChoices from django in strawberry.enum .
Contributed by Patrick Arminio PR #1202
This release improves how we deal with custom scalars. Instead of being global they are now scoped to the schema. This allows you to have multiple sch
This release improves how we deal with custom scalars. Instead of being global they are now scoped to the schema. This allows you to have multiple schemas in the same project with different scalars.
Also you can now override the built in scalars with your own custom implementation. Out of the box Strawberry provides you with custom scalars for common Python types like datetime and Decimal . If you require a custom implementation of one of these built in scalars you can now pass a map of overrides to your schema:
from datetime import datetime, timezone
import strawberry
EpochDateTime = strawberry.scalar(
datetime,
serialize = lambda value : int (value.timestamp()),
parse_value = lambda value : datetime.fromtimestamp( int (value), timezone.utc),
)
@strawberry.type
class Query :
@strawberry.field
def current_time ( self ) -> datetime:
return datetime.now()
schema = strawberry.Schema(
Query,
scalar_overrides ={
datetime: EpochDateTime,
},
)
result = schema.execute_sync( "{ currentTime }" )
assert result.data == { "currentTime" : 1628683200 }
Contributed by Jonathan Kim PR #1147
This release allows to install Strawberry along side click version 8.
This release allows to install Strawberry along side click version 8.
Contributed by Patrick Arminio PR #1181
This release add full support for async directives and fixes and issue when using directives and async extensions.
This release add full support for async directives and fixes and issue when using directives and async extensions.
@strawberry.type
class Query :
name: str = "Banana"
@strawberry.directive (
locations =[DirectiveLocation.FIELD], description = "Make string uppercase"
)
async def uppercase ( value : str ):
return value.upper()
schema = strawberry.Schema( query =Query, directives =[uppercase])
Contributed by Patrick Arminio PR #1179
Fix issue where strawberry.Private fields on converted Pydantic types were not added to the resulting dataclass.
Fix issue where strawberry.Private fields on converted Pydantic types were not added to the resulting dataclass.
Contributed by Paul Sud PR #1173
This releases fixes a MyPy issue that prevented from using types created with create_type as base classes. This is now allowed and doesn’t throw any e
This releases fixes a MyPy issue that prevented from using types created with create_type as base classes. This is now allowed and doesn’t throw any error:
import strawberry
from strawberry.tools import create_type
@strawberry.field
def name () -> str :
return "foo"
MyType = create_type( "MyType" , [name])
class Query ( MyType ): ...
Contributed by Patrick Arminio PR #1175
This release fixes an import error when trying to import create_type without having opentelemetry installed.
This release fixes an import error when trying to import create_type without having opentelemetry installed.
Contributed by Patrick Arminio PR #1171
This release adds support for the latest version of the optional opentelemetry dependency.
This release adds support for the latest version of the optional opentelemetry dependency.
Contributed by Patrick Arminio PR #1170
This release allows background tasks to be set with the ASGI integration. Tasks can be set on the response in the context, and will then get run after
This release allows background tasks to be set with the ASGI integration. Tasks can be set on the response in the context, and will then get run after the query result is returned.
from starlette.background import BackgroundTask
@strawberry.mutation
def create_flavour ( self , info : strawberry.Info) -> str :
info.context[ "response" ].background = BackgroundTask(...)
Contributed by Joe Freeman PR #1168
This release caches attributes on the Info type which aren’t delegated to the core info object.
This release caches attributes on the Info type which aren’t delegated to the core info object.
Contributed by A. Coady PR #1167
This releases fixes an issue where you were not allowed to use duck typing and return a different type that the type declared on the field when the ty
This releases fixes an issue where you were not allowed to use duck typing and return a different type that the type declared on the field when the type was implementing an interface. Now this works as long as you return a type that has the same shape as the field type.
Contributed by Patrick Arminio PR #1150
This release improves execution performance significantly by lazy loading attributes on the Info type 🏎
This release improves execution performance significantly by lazy loading attributes on the Info type 🏎
Contributed by Jonathan Kim PR #1165
One column per quarter.