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 hotfix enables permission extensions to be used with AsyncGenerators.
This hotfix enables permission extensions to be used with AsyncGenerators.
Releases contributed by @erikwrede via #3318
This hotfix enables permission extensions to be used with AsyncGenerators.
Contributed by Erik Wrede via PR #3318
Permissions classes now use a FieldExtension. The new preferred way to add permissions is to use the PermissionsExtension class:
Permissions classes now use a FieldExtension. The new preferred way to add permissions
is to use the PermissionsExtension class:
import strawberry
from strawberry.permission import PermissionExtension, BasePermission
class IsAuthorized(BasePermission):
message = "User is not authorized"
error_extensions = {"code": "UNAUTHORIZED"}
def has_permission(self, source, info, **kwargs) -> bool:
return False
@strawberry.type
class Query:
@strawberry.field(extensions=[PermissionExtension(permissions=[IsAuthorized()])])
def name(self) -> str:
return "ABC"
The old way of adding permissions using permission_classes is still
supported via the automatic addition of a PermissionExtension on the field.
Previously the kwargs argument keys for the has_permission method were
using camel casing (depending on your schema configuration), now they will
always follow the python name defined in your resolvers.
class IsAuthorized(BasePermission):
message = "User is not authorized"
def has_permission(
self, source, info, **kwargs: typing.Any
) -> bool: # pragma: no cover
# kwargs will have a key called "a_key"
# instead of `aKey`
return False
@strawberry.type
class Query:
@strawberry.field(permission_classes=[IsAuthorized])
def name(self, a_key: str) -> str: # pragma: no cover
return "Erik"
Using the new PermissionExtension API, permissions support even more features:
To return None or [] instead of raising an error, the fail_silently keyword
argument on PermissionExtension can be set to True.
Permissions will now automatically add pre-defined error extensions to the error, and
can use a custom GraphQLError class. This can be configured by modifying
the error_class and error_extensions attributes on the BasePermission class.
To customize the error handling, the on_unauthorized method on
the BasePermission class can be used. Further changes can be implemented by
subclassing the PermissionExtension class.
Permissions will automatically be added as schema directives to the schema. This
behavior can be altered by setting the add_directives to False
on PermissionExtension, or by setting the _schema_directive class attribute of the
permission to a custom directive.
Releases contributed by @erikwrede via #2570
Your coding agent can read these notes before it upgrades. Set up the MCP server →
Don't require NodeId annotation if resolve_id is overwritten on Node implemented types
Don't require NodeId annotation if resolve_id is overwritten on Node implemented types
Releases contributed by @devkral via #2844
Don't require NodeId annotation if resolve_id is overwritten on Node implemented types
Override encode_json() method in Django BaseView to use DjangoJSONEncoder
Override encode_json() method in Django BaseView to use DjangoJSONEncoder
Releases contributed by @noamsto via #3273
Override encode_json() method in Django BaseView to use DjangoJSONEncoder
Contributed by Noam Stolero via PR #3273
Fixed the base view so it uses parse_json when loading parameters from the query string instead of json.loads.
Fixed the base view so it uses parse_json when loading parameters from the query string instead of json.loads.
Releases contributed by @thearchitector via #3272
Fixed the base view so it uses parse_json when loading parameters from the query string instead of json.loads.
Contributed by Elias Gabriel via PR #3272
This release updates the Apollo Sandbox integration to all you to pass cookies to the GraphQL endpoint by enabling the Include cookes option in the Sa
This release updates the Apollo Sandbox integration to all you to pass cookies to the GraphQL endpoint by enabling the Include cookes option in the Sandbox settings.
Releases contributed by @patrick91 via #3278
This release updates the Apollo Sandbox integration to all you to pass cookies to the GraphQL endpoint by enabling the Include cookes option in the Sandbox settings.
Contributed by Patrick Arminio via PR #3278
Nothing published for this version
Improved error message when supplying GlobalID format that relates to another type than the query itself.
Improved error message when supplying GlobalID format that relates to another type than the query itself.
Releases contributed by @sdobbelaere via #3194
Improved error message when supplying GlobalID format that relates to another type than the query itself.
Adds an optional extensions parameter to strawberry.federation.field, with default value None. The key is passed through to strawberry.field, so the f
Adds an optional extensions parameter to strawberry.federation.field, with default value None. The key is passed through to strawberry.field, so the functionality is exactly as described here.
Example:
strawberry.federation.field(extensions=[InputMutationExtension()])
Releases contributed by @bricker via #3239
Adds an optional extensions parameter to strawberry.federation.field, with default value None. The key is passed through to strawberry.field, so the functionality is exactly as described here.
Example:
strawberry.federation.field(extensions=[InputMutationExtension()])
Contributed by Bryan Ricker via PR #3239
This release updates the GraphiQL packages to their latest versions:
This release updates the GraphiQL packages to their latest versions:
graphiql@3.0.9@graphiql/plugin-explorer@1.0.2Releases contributed by @rodrigofeijao via #3227
This release updates the GraphiQL packages to their latest versions:
graphiql@3.0.9@graphiql/plugin-explorer@1.0.2Contributed by Rodrigo Feijao via PR #3227
Nothing published for this version
Nothing published for this version
Nothing published for this version
Deprecations: This release deprecates the graphiql option in all HTTP integrations, in favour of graphql_ide, this allows us to only have one settings…
This release adds support in all all our HTTP integration for choosing between different GraphQL IDEs. For now we support GraphiQL (the default), Apollo Sandbox, and Pathfinder.
Deprecations: This release deprecates the graphiql option in all HTTP integrations,
in favour of graphql_ide, this allows us to only have one settings to change GraphQL ide,
or to disable it.
Here's a couple of examples of how you can use this:
import strawberry
from fastapi import FastAPI
from strawberry.fastapi import GraphQLRouter
from api.schema import schema
graphql_app = GraphQLRouter(schema, graphql_ide="apollo-sandbox")
app = FastAPI()
app.include_router(graphql_app, prefix="/graphql")
from django.urls import path
from strawberry.django.views import GraphQLView
from api.schema import schema
urlpatterns = [
path("graphql/", GraphQLView.as_view(schema=schema, graphql_ide="pathfinder")),
]
Releases contributed by @patrick91 via #3209
Nothing published for this version
Nothing published for this version
Nothing published for this version
This release changes how we check for generic types. Previously, any type that had a generic typevar would be considered generic for the GraphQL schem
This release changes how we check for generic types. Previously, any type that had a generic typevar would be considered generic for the GraphQL schema, this would generate un-necessary types in some cases. Now, we only consider a type generic if it has a typevar that is used as the type of a field or one of its arguments.
For example the following type:
@strawberry.type
class Edge[T]:
cursor: strawberry.ID
some_interna_value: strawberry.Private[T]
Will not generate a generic type in the schema, as the typevar T is not used
as the type of a field or argument.
Releases contributed by @patrick91 via #3202
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
This release removes unused graphiql submodules for Flask, Quart and Sanic.
This release removes unused graphiql submodules for Flask, Quart and Sanic.
Releases contributed by @catwell via #3203
This release removes unused graphiql submodules for Flask, Quart and Sanic.
Contributed by Pierre Chapuis via PR #3203
This release fixes an issue that prevented the parser_cache extension to be used in combination with other extensions such as MaxTokensLimiter.
This release fixes an issue that prevented the parser_cache extension to be used in combination with
other extensions such as MaxTokensLimiter.
The following should work as expected now:
schema = strawberry.Schema(
query=Query, extensions=[MaxTokensLimiter(max_token_count=20), ParserCache()]
)
Releases contributed by @Dazix via #3170
This release fixes an issue that prevented the parser_cache extension to be used in combination with
other extensions such as MaxTokensLimiter.
The following should work as expected now:
schema = strawberry.Schema(
query=Query, extensions=[MaxTokensLimiter(max_token_count=20), ParserCache()]
)
Contributed by David Šanda via PR #3170
This release adds a Quart view.
This release adds a Quart view.
Releases contributed by @catwell via #3162
This release adds a Quart view.
Contributed by Pierre Chapuis via PR #3162
This release deprecates our SentryTracingExtension, as it is now incorporated directly into Sentry itself as of version 1.32.0. You can now directly i…
This release deprecates our SentryTracingExtension, as it is now incorporated directly into Sentry itself as of version 1.32.0. You can now directly instrument Strawberry with Sentry.
Below is the revised usage example:
import sentry_sdk
from sentry_sdk.integrations.strawberry import StrawberryIntegration
sentry_sdk.init(
dsn="___PUBLIC_DSN___",
integrations=[
# make sure to set async_execution to False if you're executing
# GraphQL queries synchronously
StrawberryIntegration(async_execution=True),
],
traces_sample_rate=1.0,
)
Many thanks to @sentrivana for their work on this integration!
Releases contributed by @patrick91 via #3169
Nothing published for this version
Fix strawberry mypy plugin for pydantic v2
Fix strawberry mypy plugin for pydantic v2
Releases contributed by @Corentin-Br via #3159
Fix strawberry mypy plugin for pydantic v2
Contributed by Corentin-Br via PR #3159
Nothing published for this version
Remove stack_info from error log messages to not clutter error logging with unnecessary information.
Remove stack_info from error log messages to not clutter error logging with unnecessary information.
Releases contributed by @finsterwalder via #3143
Remove stack_info from error log messages to not clutter error logging with unnecessary information.
Contributed by Malte Finsterwalder via PR #3143
Add text/html content-type to chalice graphiql response
Add text/html content-type to chalice graphiql response
Releases contributed by @jpopesculian via #3137
Add text/html content-type to chalice graphiql response
Contributed by Julian Popescu via PR #3137
This release adds a new private hook in our HTTP views, it is called _handle_errors and it is meant to be used by Sentry (or other integrations) to ha
This release adds a new private hook in our HTTP views, it is called
_handle_errors and it is meant to be used by Sentry (or other integrations)
to handle errors without having to patch methods that could be overridden
by the users
Releases contributed by @patrick91 via #3127
This release adds a new private hook in our HTTP views, it is called
_handle_errors and it is meant to be used by Sentry (or other integrations)
to handle errors without having to patch methods that could be overridden
by the users
Contributed by Patrick Arminio via PR #3127
This release changes how we check for conflicting resolver arguments to exclude self from those checks, which were introduced on version 0.208.0.
This release changes how we check for conflicting resolver arguments to
exclude self from those checks, which were introduced on version 0.208.0.
It is a common pattern among integrations, such as the Django one, to
use root: Model in the resolvers for better typing inference.
Releases contributed by @bellini666 via #3131
This release changes how we check for conflicting resolver arguments to
exclude self from those checks, which were introduced on version 0.208.0.
It is a common pattern among integrations, such as the Django one, to
use root: Model in the resolvers for better typing inference.
Contributed by Thiago Bellini Ribeiro via PR #3131
Mark Django's asyncview as a coroutine using asgiref.sync.markcoroutinefunction to support using it with Python 3.12.
Mark Django's asyncview as a coroutine using asgiref.sync.markcoroutinefunction
to support using it with Python 3.12.
Releases contributed by @bellini666 via #3124
Mark Django's asyncview as a coroutine using asgiref.sync.markcoroutinefunction
to support using it with Python 3.12.
Contributed by Thiago Bellini Ribeiro via PR #3124
Nothing published for this version
Fix generation of input based on pydantic models using nested Annotated type annotations:
Fix generation of input based on pydantic models using nested Annotated type annotations:
import strawberry
from pydantic import BaseModel
class User(BaseModel):
age: Optional[Annotated[int, "metadata"]]
@strawberry.experimental.pydantic.input(all_fields=True)
class UserInput:
pass
Releases contributed by @gazorby via #3109
Fix generation of input based on pydantic models using nested Annotated type annotations:
import strawberry
from pydantic import BaseModel
class User(BaseModel):
age: Optional[Annotated[int, "metadata"]]
@strawberry.experimental.pydantic.input(all_fields=True)
class UserInput:
pass
Contributed by Matthieu MN via PR #3109
This release fixes an issue when trying to generate code from a schema that was using double quotes inside descriptions.
This release fixes an issue when trying to generate code from a schema that was using double quotes inside descriptions.
The following schema will now generate code correctly:
"""
A type of person or character within the "Star Wars" Universe.
"""
type Species {
"""
The classification of this species, such as "mammal" or "reptile".
"""
classification: String!
}
Releases contributed by @patrick91 via #3112
This release fixes an issue when trying to generate code from a schema that was using double quotes inside descriptions.
The following schema will now generate code correctly:
"""
A type of person or character within the "Star Wars" Universe.
"""
type Species {
"""
The classification of this species, such as "mammal" or "reptile".
"""
classification: String!
}
Contributed by Patrick Arminio via PR #3112
This release adds support for generating Strawberry types from SDL files. For example, given the following SDL file:
This release adds support for generating Strawberry types from SDL files. For example, given the following SDL file:
type Query {
user: User
}
type User {
id: ID!
name: String!
}
you can run
strawberry schema-codegen schema.graphql
to generate the following Python code:
import strawberry
@strawberry.type
class Query:
user: User | None
@strawberry.type
class User:
id: strawberry.ID
name: str
schema = strawberry.Schema(query=Query)
Releases contributed by @patrick91 via #3096
This release adds support for generating Strawberry types from SDL files. For example, given the following SDL file:
type Query {
user : User
}
type User {
id : ID !
name : String !
}
you can run
Terminal window
strawberry schema-codegen schema.graphql
to generate the following Python code:
import strawberry
@strawberry.type
class Query :
user: User | None
@strawberry.type
class User :
id : strawberry.ID
name: str
schema = strawberry.Schema( query =Query)
Contributed by Patrick Arminio via PR #3096
Adding support for additional pydantic built in types like EmailStr or PostgresDsn.
Adding support for additional pydantic built in types like EmailStr or PostgresDsn.
Releases contributed by @ppease via #3101
Adding support for additional pydantic built in types like EmailStr or PostgresDsn.
This release fixes an issue that would prevent using generics with unnamed unions, like in this example:
This release fixes an issue that would prevent using generics with unnamed unions, like in this example:
from typing import Generic, TypeVar, Union
import strawberry
T = TypeVar("T")
@strawberry.type
class Connection(Generic[T]):
nodes: list[T]
@strawberry.type
class Entity1:
id: int
@strawberry.type
class Entity2:
id: int
@strawberry.type
class Query:
entities: Connection[Union[Entity1, Entity2]]
Releases contributed by @patrick91 via #3099
This release fixes an issue that would prevent using generics with unnamed unions, like in this example:
from typing import Generic, TypeVar, Union
import strawberry
T = TypeVar("T")
@strawberry.type
class Connection(Generic[T]):
nodes: list[T]
@strawberry.type
class Entity1:
id: int
@strawberry.type
class Entity2:
id: int
@strawberry.type
class Query:
entities: Connection[Union[Entity1, Entity2]]
Contributed by Patrick Arminio via PR #3099
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
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
One column per quarter.