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.
This release fixes an issue in the graphql-ws implementation where sending a null payload would cause the connection to be closed.
This release fixes an issue in the graphql-ws implementation
where sending a null payload would cause the connection
to be closed.
Contributed by Patrick Arminio via PR #3007
This release changes how we handle generic type vars, bringing support to the new generic syntax in Python 3.12 (which will be out in October).
This release changes how we handle generic type vars, bringing support to the new generic syntax in Python 3.12 (which will be out in October).
This now works:
@strawberry.type
class Edge[T]:
cursor: strawberry.ID
node_field: T
@strawberry.type
class Query:
@strawberry.field
def example(self) -> Edge[int]:
return Edge(cursor=strawberry.ID("1"), node_field=1)
schema = strawberry.Schema(query=Query)
Contributed by Patrick Arminio via PR #2993
Your coding agent can read these notes before it upgrades. Set up the MCP server →
This release adds support for returning interfaces directly in resolvers:
This release adds support for returning interfaces directly in resolvers:
@strawberry.interface
class Node:
id: strawberry.ID
@classmethod
def resolve_type(cls, obj: Any, *args: Any, **kwargs: Any) -> str:
return "Video" if obj.id == "1" else "Image"
@strawberry.type
class Video(Node): ...
@strawberry.type
class Image(Node): ...
@strawberry.type
class Query:
@strawberry.field
def node(self, id: strawberry.ID) -> Node:
return Node(id=id)
schema = strawberry.Schema(query=Query, types=[Video, Image])
Contributed by Patrick Arminio via PR #2989
This release removes support for Python 3.7 as its end of life was on 27 Jun 2023.
Nothing published for this version
This release fixes an issue when trying to use Annotated[strawberry.auto, ...] on python 3.10 or older, which got evident after the fix from 0.196.1.
This release fixes an issue when trying to use Annotated[strawberry.auto, ...]
on python 3.10 or older, which got evident after the fix from 0.196.1.
Previously we were throwing the type away, since it usually is Any, but python
3.10 and older will validate that the first argument passed for Annotated
is callable (3.11+ does not do that anymore), and StrawberryAuto is not.
This changes it to keep that Any, which is also what someone would expect
when resolving the annotation using our custom eval_type function.
Contributed by Thiago Bellini Ribeiro via PR #2990
This release fixes an issue where annotations resolution for auto and lazy fields using Annotated where not preserving the remaining arguments because
This release fixes an issue where annotations resolution for auto and lazy fields
using Annotated where not preserving the remaining arguments because of a
typo in the arguments filtering.
Contributed by Thiago Bellini Ribeiro via PR #2983
This release adds support for union with a single member, they are useful for future proofing your schema in cases you know a field will be part of a
This release adds support for union with a single member, they are useful for future proofing your schema in cases you know a field will be part of a union in future.
import strawberry
from typing import Annotated
@strawberry.type
class Audio:
duration: int
@strawberry.type
class Query:
# note: Python's Union type doesn't support single members,
# Union[Audio] is exactly the same as Audio, so we use
# use Annotated and strawberry.union to tell Strawberry this is
# a union with a single member
latest_media: Annotated[Audio, strawberry.union("MediaItem")]
schema = strawberry.Schema(query=Query)
Contributed by Patrick Arminio via PR #2982
Nothing published for this version
Nothing published for this version
Nothing published for this version
This release no longer requires an upperbound pin for uvicorn, ensuring compatibility with future versions of uvicorn without the need for updating St
This release no longer requires an upperbound pin for uvicorn, ensuring compatibility with future versions of uvicorn without the need for updating Strawberry.
Contributed by Patrick Arminio via PR #2968
This release introduces a bug fix for relay connection where previously they wouldn't work without padding the first argument.
This release fixes a bug where returning a generic type from a field that was returning an interface would throw an error.
This release fixes a bug where returning a generic type from a field that was returning an interface would throw an error.
Contributed by Patrick Arminio via PR #2955
Improve the time complexity of strawberry.interface using resolve_type. Achieved time complexity is now O(1) with respect to the number of implementat
Improve the time complexity of strawberry.interface using resolve_type.
Achieved time complexity is now O(1) with respect to the number of
implementations of an interface. Previously, the use of is_type_of resulted
in a worst-case performance of O(n).
Before:
---------------------------------------------------------------------------
Name (time in ms) Min Max
---------------------------------------------------------------------------
test_interface_performance[1] 18.0224 (1.0) 50.3003 (1.77)
test_interface_performance[16] 22.0060 (1.22) 28.4240 (1.0)
test_interface_performance[256] 69.1364 (3.84) 76.1349 (2.68)
test_interface_performance[4096] 219.6461 (12.19) 231.3732 (8.14)
---------------------------------------------------------------------------
After:
---------------------------------------------------------------------------
Name (time in ms) Min Max
---------------------------------------------------------------------------
test_interface_performance[1] 14.3921 (1.0) 46.2064 (2.79)
test_interface_performance[16] 14.8669 (1.03) 16.5732 (1.0)
test_interface_performance[256] 15.8977 (1.10) 24.4618 (1.48)
test_interface_performance[4096] 18.7340 (1.30) 21.2899 (1.28)
---------------------------------------------------------------------------
Contributed by San Kilkis via PR #1949
This release makes sure that Schema.process_errors() is called _once_ for every error which happens with graphql-transport-ws operations.
This release makes sure that Schema.process_errors() is called once for every error
which happens with graphql-transport-ws operations.
Contributed by Kristján Valur Jónsson via PR #2899
Added default argument to the typer Argument function, this adds support for older versions of typer.
Added default argument to the typer Argument function, this adds support for older versions of typer.
Contributed by Jaime Coello de Portugal via PR #2906
This release includes a performance improvement to strawberry.lazy() to allow relative module imports to be resolved faster.
This release includes a performance improvement to strawberry.lazy() to allow relative module imports to be resolved faster.
Contributed by Karim Alibhai via PR #2926
This release adds a setter on StrawberryAnnotation.annotation, this fixes an issue on Strawberry Django.
This release adds a setter on StrawberryAnnotation.annotation, this fixes
an issue on Strawberry Django.
Contributed by Patrick Arminio via PR #2932
Restore evaled type access in StrawberryAnnotation
Restore evaled type access in StrawberryAnnotation
Prior to Strawberry 192.2 the annotation attribute of StrawberryAnnotation
would return an evaluated type when possible due reserved argument parsing.
192.2 moved the responsibility of evaluating and caching results to the
evaluate method of StrawberryAnnotation. This introduced a regression when
using future annotations for any code implicitely relying on the annotation
attribute being an evaluated type.
To fix this regression and mimick pre-192.2 behavior, this release adds an
annotation property to StrawberryAnnotation that internally calls the
evaluate method. On success the evaluated type is returned. If a NameError
is raised due to an unresolvable annotation, the raw annotation is returned.
Contributed by San Kilkis via PR #2925
This fixes a regression from 0.190.0 where changes to the return type of a field done by Field Extensions would not be taken in consideration by the s
This fixes a regression from 0.190.0 where changes to the return type of a field done by Field Extensions would not be taken in consideration by the schema.
Contributed by Thiago Bellini Ribeiro via PR #2922
This release contains a deprecation for the Channels integration. The channel_listen method will be replaced with an async context manager that return…
This release updates the API to listen to Django Channels to avoid race conditions when confirming GraphQL subscriptions.
Deprecations:
This release contains a deprecation for the Channels integration. The channel_listen
method will be replaced with an async context manager that returns an awaitable
AsyncGenerator. This method is called listen_to_channel.
An example of migrating existing code is given below:
# Existing code
@strawberry.type
class MyDataType:
name: str
@strawberry.type
class Subscription:
@strawberry.subscription
async def my_data_subscription(
self, info: strawberry.Info, groups: list[str]
) -> AsyncGenerator[MyDataType | None, None]:
yield None
async for message in info.context["ws"].channel_listen(
"my_data", groups=groups
):
yield MyDataType(name=message["payload"])
# New code
@strawberry.type
class Subscription:
@strawberry.subscription
async def my_data_subscription(
self, info: strawberry.Info, groups: list[str]
) -> AsyncGenerator[MyDataType | None, None]:
async with info.context["ws"].listen_to_channel("my_data", groups=groups) as cm:
yield None
async for message in cm:
yield MyDataType(name=message["payload"])
Contributed by Moritz Ulmer via PR #2856
This release fixes an issue related to using typing.Annotated in resolver arguments following the declaration of a reserved argument such as strawberr
This release fixes an issue related to using typing.Annotated in resolver
arguments following the declaration of a reserved argument such as
strawberry.types.Info.
Before this fix, the following would be converted incorrectly:
from __future__ import annotations
import strawberry
import uuid
from typing_extensions import Annotated
from strawberry.types import Info
@strawberry.type
class Query:
@strawberry.field
def get_testing(
self,
info: strawberry.Info,
id_: Annotated[uuid.UUID, strawberry.argument(name="id")],
) -> str | None:
return None
schema = strawberry.Schema(query=Query)
print(schema)
Resulting in the schema:
type Query {
getTesting(id_: UUID!): String # ⬅️ see `id_`
}
scalar UUID
After this fix, the schema is converted correctly:
type Query {
getTesting(id: UUID!): String
}
scalar UUID
Contributed by San Kilkis via PR #2901
Add specifications in FastAPI doc if query via GET is enabled
Add specifications in FastAPI doc if query via GET is enabled
Contributed by guillaumeLepape via PR #2913
This release introduces a new command called upgrade, this command can be used to run codemods on your codebase to upgrade to the latest version of St
This release introduces a new command called upgrade, this command can be used
to run codemods on your codebase to upgrade to the latest version of Strawberry.
At the moment we only support upgrading unions to use the new syntax with annotated, but in future we plan to add more commands to help with upgrading.
Here's how you can use the command to upgrade your codebase:
strawberry upgrade annotated-union .
Contributed by Patrick Arminio via PR #2886
This release refactors the way we resolve field types to to make it more robust, resolving some corner cases.
Nothing published for this version
This release removes some usage of deprecated functions from GraphQL-core.
This release removes some usage of deprecated functions from GraphQL-core.
Contributed by Kristján Valur Jónsson via PR #2894
The graphql-transport-ws protocol allows for subscriptions to error during execution without terminating the subscription. Non-fatal errors produced b
The graphql-transport-ws protocol allows for subscriptions to error during execution without terminating
the subscription. Non-fatal errors produced by subscriptions now produce Next messages containing
an ExecutionResult with an error field and don't necessarily terminate the subscription.
This is in accordance to the behaviour of Apollo server.
Contributed by Kristján Valur Jónsson via PR #2876
This release fixes a deprecation warning being triggered by the relay integration.
This release fixes a deprecation warning being triggered by the relay integration.
Contributed by Patrick Arminio via PR #2858
Nothing published for this version
This release updates create_type to add support for all arguments that strawberry.type supports. This includes: description, extend, directives, is_in
This release updates create_type to add support for all arguments
that strawberry.type supports. This includes: description, extend,
directives, is_input and is_interface.
Contributed by Patrick Arminio via PR #2880
This release gives codegen clients the ability to inquire about the __typename of a GraphQLObjectType. This information can be used to automatically s
This release gives codegen clients the ability to inquire about the __typename
of a GraphQLObjectType. This information can be used to automatically select
the proper type to hydrate when working with a union type in the response.
Contributed by Matt Gilson via PR #2875
This release fixes a regression when comparing a StrawberryAnnotation instance with anything that is not also a StrawberryAnnotation instance, which c
This release fixes a regression when comparing a StrawberryAnnotation
instance with anything that is not also a StrawberryAnnotation instance,
which caused it to raise a NotImplementedError.
This reverts its behavior back to how it worked before, where it returns
NotImplemented instead, meaning that the comparison can be delegated to
the type being compared against or return False in case it doesn't define
an __eq__ method.
Contributed by Thiago Bellini Ribeiro via PR #2879
graphql-transport-ws handler now uses a single dict to manage active operations.
graphql-transport-ws handler now uses a single dict to manage active operations.
Contributed by Kristján Valur Jónsson via PR #2699
This release fixes a typing regression on StraberryContainer subclasses where type checkers would not allow non WithStrawberryObjectDefinition types t
This release fixes a typing regression on StraberryContainer subclasses
where type checkers would not allow non WithStrawberryObjectDefinition types
to be passed for its of_type argument (e.g. StrawberryOptional(str))
Contributed by Thiago Bellini Ribeiro via PR #2878
This release removes get_object_definition_strict and instead overloads get_object_definition to accept an extra strct keyword.
This release removes get_object_definition_strict and instead
overloads get_object_definition to accept an extra strct keyword.
This is a new feature so it is unlikely to break anything.
Contributed by Thiago Bellini Ribeiro via PR #2877
This release bumps the minimum requirement of typing-extensions to 4.5
This release bumps the minimum requirement of
typing-extensions to 4.5
Contributed by Patrick Arminio via PR #2872
This release renames _type_definition to __strawberry_definition__. This doesn't change the public API of Strawberry, but if you were using _type_defi
This release adds resolve_async to NodeExtension to allow it to be used together with other field async extensions/permissions.
This release adds resolve_async to NodeExtension to allow it to be used together with other field async extensions/permissions.
Contributed by Thiago Bellini Ribeiro via PR #2863
This release fixes an issue on StrawberryField.copy_with method not copying its extensions and overwritten _arguments.
This release fixes an issue on StrawberryField.copy_with method
not copying its extensions and overwritten _arguments.
Also make sure that all lists/tuples in those types are copied as new lists/tuples to avoid unexpected behavior.
Contributed by Thiago Bellini Ribeiro via PR #2865
In this release, we pass the default values from the strawberry.Schema through to the codegen plugins. The default python plugin now adds these defaul
In this release, we pass the default values from the strawberry.Schema through to the codegen plugins. The default python plugin now adds these default values to the objects it generates.
Contributed by Matt Gilson via PR #2860
This release removes more parts of the Mypy plugin, since they are not needed anymore.
This release removes more parts of the Mypy plugin, since they are not needed anymore.
Contributed by Patrick Arminio via PR #2852
This release fixes a bug causing a KeyError exception to be thrown during subscription cleanup.
Nothing published for this version
Correct a type-hinting bug with strawberry.directive. This may cause some consumers to have to remove a # type: ignore comment or unnecessary typing.c
Correct a type-hinting bug with strawberry.directive.
This may cause some consumers to have to remove a # type: ignore comment
or unnecessary typing.cast in order to get mypy to pass.
Contributed by Matt Gilson via PR #2847
This release removes our custom __dataclass_transform__ decorator and replaces it with typing-extension's one. It also removes parts of the mypy plugi
This release removes our custom __dataclass_transform__ decorator and replaces
it with typing-extension's one. It also removes parts of the mypy plugin, since
most of it is not needed anymore 🙌
This update requires typing_extensions>=4.1.0
Contributed by Patrick Arminio via PR #2227
This release migrates our CLI to typer, all commands should work the same as before.
This release migrates our CLI to typer, all commands should work the same as before.
Contributed by Patrick Arminio via PR #2569
This release improves the relay.NodeID annotation check by delaying it until after class initialization. This resolves issues with evaluating type an
This release improves the relay.NodeID annotation check by delaying it until after class initialization. This resolves issues with evaluating type annotations before they are fully defined and enables integrations to inject code for it in the type.
Contributed by Thiago Bellini Ribeiro via PR #2838
This release fixes a bug in the codegen where List objects are currently emitted as Optional objects.
This release fixes a bug in the codegen where List objects are currently emitted
as Optional objects.
Contributed by Matt Gilson via PR #2843
Refactor ConnectionExtension to copy arguments instead of extending them. This should fix some issues with integrations which override arguments, like
Refactor ConnectionExtension to copy arguments instead of extending them.
This should fix some issues with integrations which override arguments,
like the django one, where the inserted arguments were vanishing.
Contributed by Thiago Bellini Ribeiro via PR #2839
This release fixes a bug where codegen would fail on mutations that have object arguments in the query.
This release fixes a bug where codegen would fail on mutations that have object arguments in the query.
Additionally, it does a topological sort of the types before passing it to the plugins to ensure that dependent types are defined after their dependencies.
Contributed by Matt Gilson via PR #2831
This release fixes an issue where Strawberry would make copies of types that were using specialized generics that were not Strawerry types.
This release fixes an issue where Strawberry would make copies of types that were using specialized generics that were not Strawerry types.
This issue combined with the use of lazy types was resulting in duplicated type errors.
Contributed by Patrick Arminio via PR #2824
This release fixes an issue for parsing lazy types using forward references when they were enclosed in an Optional[...] type.
This release fixes an issue for parsing lazy types using forward references
when they were enclosed in an Optional[...] type.
The following now should work properly:
from __future__ import annotations
from typing import Optional, Annotated
import strawberry
@strawberry.type
class MyType:
other_type: Optional[Annotated["OtherType", strawberry.lazy("some.module")]]
# or like this
other_type: Annotated["OtherType", strawberry.lazy("some.module")] | None
Contributed by Thiago Bellini Ribeiro via PR #2821
This release fixes a codegen bug. Prior to this fix, inline fragments would only include the last field defined within its scope and all fields common
This release fixes a codegen bug. Prior to this fix, inline fragments would only include the last field defined within its scope and all fields common with its siblings.
After this fix, all fields will be included in the generated types.
Contributed by Matt Gilson via PR #2819
Fields with generics support directives.
This release fixes an issue of the new relay integration adding an id: GlobalID! argument on all objects that inherit from relay.Node. That should've
This release fixes an issue of the new relay integration adding an id: GlobalID!
argument on all objects that inherit from relay.Node. That should've only happened
for Query types.
Strawberry now will not force a relay.Node or any type that inherits it to be
inject the node extension which adds the argument and a resolver for it, meaning that
this code:
import strawberry
from strawberry import relay
@strawberry.type
class Fruit(relay.Node):
id: relay.NodeID[int]
@strawberry.type
class Query:
node: relay.Node
fruit: Fruit
Should now be written as:
import strawberry
from strawberry import relay
@strawberry.type
class Fruit(relay.Node):
id: relay.NodeID[int]
@strawberry.type
class Query:
node: relay.Node = relay.node() # <- note the "= relay.node()" here
fruit: Fruit = relay.node()
Contributed by Thiago Bellini Ribeiro via PR #2814
Nothing published for this version
This release adds a new field extension called InputMutationExtension, which makes it easier to create mutations that receive a single input type call
This release adds a new field extension called InputMutationExtension, which makes
it easier to create mutations that receive a single input type called input,
while still being able to define the arguments of that input on the resolver itself.
The following example:
import strawberry
from strawberry.field_extensions import InputMutationExtension
@strawberry.type
class Fruit:
id: strawberry.ID
name: str
weight: float
@strawberry.type
class Mutation:
@strawberry.mutation(extensions=[InputMutationExtension()])
def update_fruit_weight(
self,
info: strawberry.Info,
id: strawberry.ID,
weight: Annotated[
float,
strawberry.argument(description="The fruit's new weight in grams"),
],
) -> Fruit:
fruit = ... # retrieve the fruit with the given ID
fruit.weight = weight
... # maybe save the fruit in the database
return fruit
Would generate a schema like this:
input UpdateFruitInput {
id: ID!
"""
The fruit's new weight in grams
"""
weight: Float!
}
type Fruit {
id: ID!
name: String!
weight: Float!
}
type Mutation {
updateFruitWeight(input: UpdateFruitInput!): Fruit!
}
Contributed by Thiago Bellini Ribeiro via PR #2580
Initial relay spec implementation. For information on how to use it, check out the docs in here: https://strawberry.rocks/docs/guides/relay
Initial relay spec implementation. For information on how to use it, check out the docs in here: https://strawberry.rocks/docs/guides/relay
Contributed by Thiago Bellini Ribeiro via PR #2511
One column per quarter.