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.
Change strawberry.auto to be a type instead of a sentinel. This not only removes the dependency on sentinel from the project, but also fixes some rela
Change strawberry.auto to be a type instead of a sentinel. This not only removes the dependency on sentinel from the project, but also fixes some related issues, like the fact that only types can be used with Annotated .
Also, custom scalars will now trick static type checkers into thinking they returned their wrapped type. This should fix issues with pyright 1.1.224+ where it doesn’t allow non-type objects to be used as annotations for dataclasses and dataclass-alike classes (which is strawberry’s case). The change to strawberry.auto also fixes this issue for it.
Contributed by Thiago Bellini Ribeiro PR #1690
This release adds support for flask 2.x and also relaxes the requirements for Django, allowing to install newer version of Django without having to wa
This release adds support for flask 2.x and also relaxes the requirements for Django, allowing to install newer version of Django without having to wait for Strawberry to update its supported dependencies list.
Contributed by Guillaume Andreu Sabater PR #1687
Your coding agent can read these notes before it upgrades. Set up the MCP server →
This fixes the schema printer to add support for schema directives on input types.
This fixes the schema printer to add support for schema directives on input types.
Contributed by Patrick Arminio PR #1697
This release fixed a false positive deprecation warning related to our AIOHTTP class based view.
This release fixed a false positive deprecation warning related to our AIOHTTP class based view.
Contributed by Jonathan Ehwald PR #1691
This release adds the following scalar types:
This release adds the following scalar types:
JSON
Base16
Base32
Base64
they can be used like so:
from strawberry.scalar import Base16, Base32, Base64, JSON
@strawberry.type
class Example :
a: Base16
b: Base32
c: Base64
d: JSON
Contributed by Paulo Costa PR #1647
Adds support for converting pydantic conlist. Note that constraint is not enforced in the graphql type. Thus, we recommend always working on the pydan
Adds support for converting pydantic conlist. Note that constraint is not enforced in the graphql type. Thus, we recommend always working on the pydantic type such that the validation is enforced.
import strawberry
from pydantic import BaseModel, conlist
class Example ( BaseModel ):
friends: conlist( str , min_items = 1 )
@strawberry.experimental.pydantic.input ( model =Example, all_fields = True )
class ExampleGQL : ...
@strawberry.type
class Query :
@strawberry.field ()
def test ( self , example : ExampleGQL) -> None :
print (example.friends)
print (example.to_pydantic().friends)
schema = strawberry.Schema( query =Query)
The converted graphql type is
input ExampleGQL {
friends: [String!]!
}
Contributed by James Chua PR #1656
Make sure you take a look at graphql-core ’s release notes for any potential breaking change that might affect you if you’re importing things from the…
This release updates graphql-core to 3.2.0
Make sure you take a look at graphql-core ’s release notes for any potential breaking change that might affect you if you’re importing things from the graphql package directly.
Contributed by Patrick Arminio PR #1601
It is now possible to have a resolver that returns “None”. Strawberry will automatically assign the new Void scalar in the schema and will always send
Support “void” functions
It is now possible to have a resolver that returns “None”. Strawberry will automatically assign the new Void scalar in the schema and will always send null in the response
Add better support for custom Pydantic conversion logic and standardize the behavior when not using strawberry.auto as the type.
Add better support for custom Pydantic conversion logic and standardize the behavior when not using strawberry.auto as the type.
See https://strawberry.rocks/docs/integrations/pydantic#custom-conversion-logic for details and examples.
Note that this release fixes a bug related to Pydantic aliases in schema generation. If you have a field with the same name as an aliased Pydantic field but with a different type than strawberry.auto , the generated field will now use the alias name. This may cause schema changes on upgrade in these cases, so care should be taken. The alias behavior can be disabled by setting the use_pydantic_alias option of the decorator to false.
Contributed by Matt Allen PR #1629
Adds support for use_pydantic_alias parameter in pydantic model conversion. Decides if the all the GraphQL field names for the generated type should u
Adds support for use_pydantic_alias parameter in pydantic model conversion. Decides if the all the GraphQL field names for the generated type should use the alias name or not.
from pydantic import BaseModel, Field
import strawberry
class UserModel ( BaseModel ):
id : int = Field(..., alias = "my_alias_name" )
@strawberry.experimental.pydantic.type (UserModel, use_pydantic_alias = False )
class User :
id : strawberry.auto
If use_pydantic_alias is False , the GraphQL type User will use id for the name of the id field coming from the Pydantic model.
type User {
id: Int!
}
With use_pydantic_alias set to True (the default behaviour) the GraphQL type user will use myAliasName for the id field coming from the Pydantic models (since the field has a alias specified`)
type User {
myAliasName: Int!
}
use_pydantic_alias is set to True for backwards compatibility.
Contributed by James Chua PR #1546
This release adds compatibility with uvicorn 0.17
This release adds compatibility with uvicorn 0.17
Contributed by dependabot PR #1627
This release fixes an issue with FastAPI context dependency injection that causes class-based custom contexts to no longer be permitted.
This release fixes an issue with FastAPI context dependency injection that causes class-based custom contexts to no longer be permitted.
Contributed by Tommy Smith PR #1564
This release fixes an issue with the name generation for nested generics, the following:
This release fixes an issue with the name generation for nested generics, the following:
T = TypeVar( "T" )
K = TypeVar( "K" )
V = TypeVar( "V" )
@strawberry.type
class Value (Generic[T]):
value: T
@strawberry.type
class DictItem (Generic[K, V]):
key: K
value: V
@strawberry.type
class Query :
d: Value[List[DictItem[ int , str ]]]
now yields the correct schema:
type IntStrDictItem {
key : Int !
value : String !
}
type IntStrDictItemListValue {
value : [ IntStrDictItem !]!
}
type Query {
d : IntStrDictItemListValue !
}
Contributed by Patrick Arminio PR #1621
Fix bug #1504 in the Pydantic integration, where it was impossible to define both an input and output type based on the same Pydantic base class.
Fix bug #1504 in the Pydantic integration, where it was impossible to define both an input and output type based on the same Pydantic base class.
Contributed by Matt Allen PR #1592
Adds to_pydantic and from_pydantic type hints for IDE support.
Adds to_pydantic and from_pydantic type hints for IDE support.
Adds mypy extension support as well.
from pydantic import BaseModel
import strawberry
class UserPydantic ( BaseModel ):
age: int
@strawberry.experimental.pydantic.type (UserPydantic)
class UserStrawberry :
age: strawberry.auto
reveal_type(UserStrawberry( age = 123 ).to_pydantic())
Mypy will infer the type as “UserPydantic”. Previously it would be “Any”
Contributed by James Chua PR #1544
This release replaces cached_property with backports.cached_property to improve the typing of the library.
This release replaces cached_property with backports.cached_property to improve the typing of the library.
Contributed by Rishi Kumar Ray PR #1582
Nothing published for this version
Nothing published for this version
Improve typing of @strawberry.enum() by:
Improve typing of @strawberry.enum() by:
@strawberry.enum
class IceCreamFlavour ( Enum ):
VANILLA = "vanilla"
STRAWBERRY = "strawberry"
CHOCOLATE = "chocolate"
Prior to this change, pyright would complain if you tried to access IceCreamFlavour.VANILLA , since the type information of IceCreamFlavour was being erased by the EnumMeta typing .
Contributed by Tim Joseph Dumol PR #1568
This release adds load_many to DataLoader .
This release adds load_many to DataLoader .
Contributed by Silas Sewell PR #1528
This release adds deprecation_reason support to arguments and mutations.
This release adds deprecation_reason support to arguments and mutations.
Contributed by Silas Sewell PR #1527
This release checks for AutoFieldsNotInBaseModelError when converting from pydantic models. It is raised when strawberry.auto is used, but the pydanti
This release checks for AutoFieldsNotInBaseModelError when converting from pydantic models. It is raised when strawberry.auto is used, but the pydantic model does not have the particular field defined.
class User ( BaseModel ):
age: int
@strawberry.experimental.pydantic.type (User)
class UserType :
age: strawberry.auto
password: strawberry.auto
Previously no errors would be raised, and the password field would not appear on graphql schema. Such mistakes could be common during refactoring. Now, AutoFieldsNotInBaseModelError is raised.
Contributed by James Chua PR #1551
Fixes TypeError when converting a pydantic BaseModel with NewType field
Fixes TypeError when converting a pydantic BaseModel with NewType field
Contributed by James Chua PR #1547
This release allows setting http headers and custom http status codes with FastAPI GraphQLRouter.
This release allows setting http headers and custom http status codes with FastAPI GraphQLRouter.
Contributed by David Němec PR #1537
Fix compatibility with Sanic 21.12
Fix compatibility with Sanic 21.12
Contributed by Artjoms Iskovs PR #1520
Add support for piping StrawberryUnion and None when annotating types.
Add support for piping StrawberryUnion and None when annotating types.
For example:
@strawberry.type
class Cat :
name: str
@strawberry.type
class Dog :
name: str
Animal = strawberry.union( "Animal" , (Cat, Dog))
@strawberry.type
class Query :
animal: Animal | None # This line no longer triggers a TypeError
Contributed by Yossi Rozantsev PR #1540
This release fixes the conversion of pydantic models with a default_factory field.
This release fixes the conversion of pydantic models with a default_factory field.
Contributed by James Chua PR #1538
This release allows conversion of pydantic models with mutable default fields into strawberry types. Also fixes bug when converting a pydantic model f
This release allows conversion of pydantic models with mutable default fields into strawberry types. Also fixes bug when converting a pydantic model field with default_factory. Previously it would raise an exception when fields with a default_factory were declared before fields without defaults.
Contributed by James Chua PR #1491
This release updates the Decimal and UUID scalar parsers to exclude the original_error exception and format the error message similar to other builtin
This release updates the Decimal and UUID scalar parsers to exclude the original_error exception and format the error message similar to other builtin scalars.
Contributed by Silas Sewell PR #1507
Fix mypy plugin crushes when _get_type_for_expr is used on var nodes
Fix mypy plugin crushes when _get_type_for_expr is used on var nodes
Contributed by Andrii Kohut PR #1513
This release fixes a bug in the annotation parser that prevents using strict typinh for Optional arguments which have their default set to UNSET.
This release fixes a bug in the annotation parser that prevents using strict typinh for Optional arguments which have their default set to UNSET.
Contributed by Sarah Henkens PR #1467
This release adds support for mypy 0.920.
This release adds support for mypy 0.920.
Contributed by Yossi Rozantsev PR #1503
This releases fixes a bug with the opentracing extension where the tracer wasn’t replacing the field name correctly.
This releases fixes a bug with the opentracing extension where the tracer wasn’t replacing the field name correctly.
This release modifies the internal utility function await_maybe towards updating mypy to 0.920.
This release modifies the internal utility function await_maybe towards updating mypy to 0.920.
Contributed by Yossi Rozantsev PR #1505
Change context_getter in strawberry.fastapi.GraphQLRouter to merge, rather than overwrite, default and custom getters.
Change context_getter in strawberry.fastapi.GraphQLRouter to merge, rather than overwrite, default and custom getters.
This mean now you can always access the request instance from info.context , even when using a custom context getter.
Contributed by Tommy Smith PR #1494
This release changes when we fetch the event loop in dataloaders to prevent using the wrong event loop in some occasions.
This release changes when we fetch the event loop in dataloaders to prevent using the wrong event loop in some occasions.
Contributed by Patrick Arminio PR #1498
This release fixes an issue that prevented from lazily importing enum types using LazyType.
This release fixes an issue that prevented from lazily importing enum types using LazyType.
Contributed by Patrick Arminio PR #1501
Nothing published for this version
This release allows running strawberry as a script, for example, you can start the debug server with the following command:
This release allows running strawberry as a script, for example, you can start the debug server with the following command:
Terminal window
python -m strawberry server schema
Contributed by YogiLiu PR #1481
This release adds support for uvicorn 0.16
This release adds support for uvicorn 0.16
Contributed by dependabot PR #1487
This fixes the previous release that introduced a direct dependency on Django.
This fixes the previous release that introduced a direct dependency on Django.
Contributed by Guillaume Andreu Sabater PR #1489
This release adds support for Django 4.0
This release adds support for Django 4.0
Contributed by Guillaume Andreu Sabater PR #1484
This release operation_type to the ExecutionContext type that is available in extensions. It also gets the operation_name from the query if one isn’t
This release operation_type to the ExecutionContext type that is available in extensions. It also gets the operation_name from the query if one isn’t provided by the client.
Contributed by Jonathan Kim PR #1286
This release adds support for passing json_encoder and json_dumps_params to Django JsonResponse via a view.
This release adds support for passing json_encoder and json_dumps_params to Django JsonResponse via a view.
from json import JSONEncoder
from django.urls import path
from strawberry.django.views import AsyncGraphQLView
from .schema import schema
.as_viewurlpatterns = [
path(
"graphql" ,
AsyncGraphQLView.as_view(
schema =schema,
json_encoder =JSONEncoder,
json_dumps_params ={ "separators" : ( "," , ":" )},
),
),
]
class CustomAsyncGraphQLView ( AsyncGraphQLView ):
json_encoder = JSONEncoder
json_dumps_params = { "separators" : ( "," , ":" )}
Contributed by Illia Volochii PR #1472
Fix cross-module type resolving for fields and resolvers
Fix cross-module type resolving for fields and resolvers
The following two issues are now fixed:
A field with a generic (typeless) resolver looks up the type relative to the resolver and not the class the field is defined in. (#1448)
When inheriting fields from another class the origin of the fields are set to the inheriting class and not the class the field is defined in.
Both these issues could lead to a rather undescriptive error message:
TypeError: (…) fields cannot be resolved. Unexpected type ‘None’
Contributed by Michael P. Jung PR #1449
This releases fixes an issue where you were not allowed to return a non-strawberry type for fields that return an interface. Now this works as long as
This releases fixes an issue where you were not allowed to return a non-strawberry type for fields that return an interface. Now this works as long as each type implementing the interface implements an is_type_of classmethod. Previous automatic duck typing on types that implement an interface now requires explicit resolution using this classmethod.
Contributed by Etty PR #1299
This release adds a GraphQLTestClient . It hides the http request’s details and asserts that there are no errors in the response (you can always disab
This release adds a GraphQLTestClient . It hides the http request’s details and asserts that there are no errors in the response (you can always disable this behavior by passing asserts_errors=False ). This makes it easier to test queries and makes your tests cleaner.
If you are using pytest you can add a fixture in conftest.py
import pytest
from django.test.client import Client
from strawberry.django.test import GraphQLTestClient
@pytest.fixture
def graphql_client ():
yield GraphQLTestClient(Client())
And use it everywere in your test methods
def test_strawberry ( graphql_client ):
query = """
query Hi($name: String!) {
hi(name: $name)
}
"""
result = graphql_client.query(query, variables ={ "name" : "Marcotte" })
assert result.data == { "hi" : "Hi Marcotte!" }
It can be used to test the file uploads as well
from django.core.files.uploadedfile import SimpleUploadedFile
def test_upload ( graphql_client ):
f = SimpleUploadedFile( "file.txt" , b "strawberry" )
query = """
mutation($textFile: Upload!) {
readText(textFile: $textFile)
}
"""
response = graphql_client.query(
query =query,
variables ={ "textFile" : None },
files ={ "textFile" : f},
)
assert response.data[ "readText" ] == "strawberry"
Contributed by Etty PR #1225
This release fixes an issue that prevented using enums as arguments for generic types inside unions.
This release fixes an issue that prevented using enums as arguments for generic types inside unions.
Contributed by Patrick Arminio PR #1463
This release fixes the message of InvalidFieldArgument to properly show the field’s name in the error message.
This release fixes the message of InvalidFieldArgument to properly show the field’s name in the error message.
Contributed by Etty PR #1322
This release fixes an issue that prevented using classmethod s and staticmethod s as resolvers
This release fixes an issue that prevented using classmethod s and staticmethod s as resolvers
import strawberry
@strawberry.type
class Query :
@strawberry.field
@ staticmethod
def static_text () -> str :
return "Strawberry"
@strawberry.field
@ classmethod
def class_name ( cls ) -> str :
return cls . name
Contributed by Illia Volochii PR #1430
This release improves type checking support for strawberry.union and now allows to use unions without any type issue, like so:
This release improves type checking support for strawberry.union and now allows to use unions without any type issue, like so:
@strawberry.type
class User :
name: str
@strawberry.type
class Error :
message: str
UserOrError = strawberry.union( "UserOrError" , (User, Error))
x: UserOrError = User( name = "Patrick" )
Contributed by Patrick Arminio PR #1438
Fix init of Strawberry types from pydantic by skipping fields that have resolvers.
Fix init of Strawberry types from pydantic by skipping fields that have resolvers.
Contributed by Nina PR #1451
This release fixes an issubclass test failing for Literal s in the experimental pydantic integration.
This release fixes an issubclass test failing for Literal s in the experimental pydantic integration.
Contributed by Nina PR #1445
This release changes how strawberry.Private is implemented to improve support for type checkers.
This release changes how strawberry.Private is implemented to improve support for type checkers.
Contributed by Patrick Arminio PR #1437
This release adds support for AWS Chalice. A framework for deploying serverless applications using AWS.
This release adds support for AWS Chalice. A framework for deploying serverless applications using AWS.
A view for aws chalice has been added to the strawberry codebase. This view embedded in a chalice app allows anyone to get a GraphQL API working and hosted on AWS in minutes using a serverless architecture.
Contributed by Mark Sheehan PR #923
This release fixes the naming generation of generics when passing a generic type to another generic, like so:
This release fixes the naming generation of generics when passing a generic type to another generic, like so:
@strawberry.type
class Edge (Generic[T]):
node: T
@strawberry.type
class Connection (Generic[T]):
edges: List[T]
Connection[Edge[ int ]]
Contributed by Patrick Arminio PR #1436
This releases updates the typing_extension dependency to latest version.
This releases updates the typing_extension dependency to latest version.
Contributed by dependabot PR #1417
This release renames an internal exception from NotAnEnum to ObjectIsNotAnEnumError .
This release renames an internal exception from NotAnEnum to ObjectIsNotAnEnumError .
Contributed by Patrick Arminio PR #1317
This release changes how we handle GraphQL names. It also introduces a new configuration option called name_converter . This option allows you to spec
This release changes how we handle GraphQL names. It also introduces a new configuration option called name_converter . This option allows you to specify a custom NameConverter to be used when generating GraphQL names.
This is currently not documented because the API will change slightly in future as we are working on renaming internal types.
This release also fixes an issue when creating concrete types from generic when passing list objects.
Contributed by Patrick Arminio PR #1394
This release fixes our MyPy plugin and re-adds support for typechecking classes created with the apollo federation decorator.
This release fixes our MyPy plugin and re-adds support for typechecking classes created with the apollo federation decorator.
Contributed by Patrick Arminio PR #1414
One column per quarter.