NewYour coding agent can read the release notes before it upgrades.Set up the MCP server →
PyPI · #1727 most downloaded on PyPI
A library for creating GraphQL APIs
Last release 19 days ago
07 Sep 2026
Ships fairly regularly
a new release about every 2 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
1114 releases · first in 2019
This fixes a bug where codegen would choke trying to find a field in the schema for a generic type.
This fixes a bug where codegen would choke trying to find a field in the schema for a generic type.
Releases contributed by @mgilson via #3077
This fixes a bug where codegen would choke trying to find a field in the schema for a generic type.
Contributed by Matt Gilson via PR #3077
Adds new strawberry.Parent type annotation to support resolvers without use of self.
Adds new strawberry.Parent type annotation to support resolvers without use of self.
E.g.
@dataclass
class UserRow:
id_: str
@strawberry.type
class User:
@strawberry.field
@staticmethod
async def name(parent: strawberry.Parent[UserRow]) -> str:
return f"User Number {parent.id}"
@strawberry.type
class Query:
@strawberry.field
def user(self) -> User:
return UserRow(id_="1234")
Releases contributed by @mattalbr via #3017
One column per quarter.
Adds new strawberry.Parent type annotation to support resolvers without use of self.
E.g.
@dataclass
class UserRow:
id_: str
@strawberry.type
class User:
@strawberry.field
@staticmethod
async def name(parent: strawberry.Parent[UserRow]) -> str:
return f"User Number {parent.id_}"
@strawberry.type
class Query:
@strawberry.field
def user(self) -> User:
return UserRow(id_="1234")
This fixes a bug where codegen would choke on FragmentSpread nodes in the GraphQL during type collection.
This fixes a bug where codegen would choke on FragmentSpread nodes in the GraphQL during type collection.
e.g.:
fragment PartialBlogPost on BlogPost {
title
}
query OperationName {
interface {
id
... on BlogPost {
...PartialBlogPost
}
... on Image {
url
}
}
}
The current version of the code generator is not able to handle the ...PartialBogPost in this position because it assumes it can only find Field type nodes even though the spread should be legit.
Contributed by Matt Gilson via PR #3086
This release removes the deprecated ignore argument from the QueryDepthLimiter extension.
This release removes the deprecated ignore argument from the QueryDepthLimiter extension.
Contributed by Kai Benevento via PR #3093
strawberry codegen can now operate on multiple input query files. The previous behavior of naming the file types.js and types.py for the builtin types
strawberry codegen can now operate on multiple input query files.
The previous behavior of naming the file types.js and types.py
for the builtin typescript and python plugins respectively is
preserved, but only if a single query file is passed. When more
than one query file is passed, the code generator will now use
the stem of the query file's name to construct the name of the
output files. e.g. my_query.graphql -> my_query.js or
my_query.py. Creators of custom plugins are responsible
for controlling the name of the output file themselves. To
accomodate this, if the __init__ method of a QueryCodegenPlugin
has a parameter named query or query_file, the pathlib.Path
to the query file will be passed to the plugin's __init__
method.
Finally, the ConsolePlugin has also recieved two new lifecycle
methods. Unlike other QueryCodegenPlugin, the same instance of
the ConsolePlugin is used for each query file processed. This
allows it to keep state around how many total files were processed.
The ConsolePlugin recieved two new lifecycle hooks: before_any_start
and after_all_finished that get called at the appropriate times.
Contributed by Matt Gilson via PR #2911
strawberry codegen previously choked for inputs that used the strawberry.UNSET sentinal singleton value as a default. The intent here is to say that i
strawberry codegen previously choked for inputs that used the
strawberry.UNSET sentinal singleton value as a default. The intent
here is to say that if a variable is not part of the request payload,
then the UNSET default value will not be modified and the service
code can then treat an unset value differently from a default value,
etc.
For codegen, we treat the UNSET default value as a GraphQLNullValue.
The .value property is the UNSET object in this case (instead of
the usual None). In the built-in python code generator, this causes
the client to generate an object with a None default. Custom client
generators can sniff at this value and update their behavior.
Contributed by Matt Gilson via PR #3050
Adds a new flag to export-schema command, --output, which allows the user to specify the output file. If unset (current behavior), the command will co
Mark pydantic constrained list test with need_pydantic_v1 since it is removed in pydantic V2
Improved pydantic conversion compatibility with specialized list classes.
Enhancements:
StrawberryAnnotation._is_list to check if the annotation extends from the list type, enabling it to be considered a list.StrawberryAnnotation Moved the _is_list check before the _is_generic check in resolve to avoid unsupported error in _is_generic before it checked _is_list.This enhancement enables the usage of constrained lists as class types and allows the creation of specialized lists. The following example demonstrates this feature:
import strawberry
from pydantic import BaseModel, ConstrainedList
class FriendList(ConstrainedList):
min_items = 1
class UserModel(BaseModel):
age: int
friend_names: FriendList[str]
@strawberry.experimental.pydantic.type(UserModel)
class User:
age: strawberry.auto
friend_names: strawberry.auto
This release updates the built-in GraphiQL to the current latest version (3.0.5), it also updates React to the current latest version (18.2.0) and use
Nothing published for this version
Add support for extra colons in the GlobalID string.
Add support for extra colons in the GlobalID string.
Before, the string SomeType:some:value would produce raise an error saying that
it was expected the string to be splited in 2 parts when doing .split(":").
Now we are using .split(":", 1), meaning that the example above will consider
SomeType to be the type name, and some:value to be the node_id.
Contributed by Thiago Bellini Ribeiro via PR #3025
TypingUnionType import error check is reraised because TypingGenericAlias is checked at the same time which is checked under 3.9 instead of under 3.10
This release updates Strawberry's codebase to use new features in Python 3.8. It also removes backports.cached-property from our dependencies, as we c
This release updates Strawberry's codebase to use new features in Python 3.8.
It also removes backports.cached-property from our dependencies, as we can
now rely on the standard library's functools.cached_property.
Contributed by Thiago Bellini Ribeiro via PR #2995
Fix strawberry mypy plugin for pydantic v1
Fix import error in strawberry.ext.mypy_plugin for users who don't use pydantic.
Fix import error in strawberry.ext.mypy_plugin for users who don't use pydantic.
Contributed by David Němec via PR #3018
Adds initial support for pydantic V2.
Adds initial support for pydantic V2.
This is extremely experimental for wider initial testing.
We do not encourage using this in production systems yet.
Contributed by James Chua via PR #2972
This release fixes an issue on relay.ListConnection where async iterables that returns non async iterable objects after being sliced where producing e
This release fixes an issue on relay.ListConnection where async iterables that returns
non async iterable objects after being sliced where producing errors.
This should fix an issue with async strawberry-graphql-django when returning already prefetched QuerySets.
Contributed by Thiago Bellini Ribeiro via PR #3014
This releases improves how we handle Annotated and async types (used in subscriptions). Previously we weren't able to use unions with names inside sub
This releases improves how we handle Annotated and async types (used in subscriptions). Previously we weren't able to use unions with names inside subscriptions, now that's fixed 😊
Example:
@strawberry.type
class A:
a: str
@strawberry.type
class B:
b: str
@strawberry.type
class Query:
x: str = "Hello"
@strawberry.type
class Subscription:
@strawberry.subscription
async def example_with_union(self) -> AsyncGenerator[Union[A, B], None]:
yield A(a="Hi")
Contributed by Patrick Arminio via PR #3008
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
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
Your coding agent can read these notes before it upgrades. Set up the MCP server →