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 11 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.
Nothing published for this version
Allow use of implicit Any in strawberry.Private annotated Generic types.
Allow use of implicit Any in strawberry.Private annotated Generic types.
For example the following is now supported:
from future import annotations
from typing import Generic, Sequence, TypeVar
import strawberry
T = TypeVar( "T" )
@strawberry.type
class Foo (Generic[T]):
private_field: strawberry.Private[Sequence] # instead of Sequence[Any]
@strawberry.type
class Query :
@strawberry.field
def foo ( self ) -> Foo[ str ]:
return Foo( private_field =[ 1 , 2 , 3 ])
See Issue #1938 for details.
Contributed by San Kilkis via PR #1939
The federation decorator now allows for a list of additional arbitrary schema directives extending the key/shareable directives used for federation.
The federation decorator now allows for a list of additional arbitrary schema directives extending the key/shareable directives used for federation.
Example Python:
import strawberry
from strawberry.schema.config import StrawberryConfig
from strawberry.schema_directive import Location
@strawberry.schema_directive ( locations =[Location.OBJECT])
class CacheControl :
max_age: int
@strawberry.federation.type (
keys =[ "id" ], shareable = True , extend = True , directives =[CacheControl( max_age = 42 )]
)
class FederatedType :
id : strawberry.ID
schema = strawberry.Schema( query =Query, config =StrawberryConfig( auto_camel_case = False ))
Resulting GQL Schema:
directive @CacheControl ( max_age : Int !) on OBJECT
directive @key ( fields : _FieldSet !, resolvable : Boolean ) on OBJECT | INTERFACE
directive @shareable on FIELD_DEFINITION | OBJECT
extend type FederatedType
@key ( fields : "id" )
@shareable
@CacheControl ( max_age : 42 ) {
id : ID !
}
type Query {
federatedType : FederatedType !
}
Contributed by Jeffrey DeFond via PR #1945
Your coding agent can read these notes before it upgrades. Set up the MCP server →
This release adds support in Mypy for using strawberry.mutation while passing a resolver, the following now doesn’t make Mypy return an error:
This release adds support in Mypy for using strawberry.mutation while passing a resolver, the following now doesn’t make Mypy return an error:
import strawberry
def set_name ( self , name : str ) -> None :
self .name = name
@strawberry.type
class Mutation :
set_name: None = strawberry.mutation( resolver =set_name)
Contributed by Etty via PR #1966
This release fixes the type annotation of Response.errors used in the GraphQLTestClient to be a List of GraphQLFormattedError .
This release fixes the type annotation of Response.errors used in the GraphQLTestClient to be a List of GraphQLFormattedError .
Contributed by Etty via PR #1961
This release fixes the type annotation of Response.errors used in the GraphQLTestClient to be a List of GraphQLError .
This release fixes the type annotation of Response.errors used in the GraphQLTestClient to be a List of GraphQLError .
Contributed by Etty via PR #1959
This release fixes an issue in the GraphQLTestClient when using both variables and files together.
This release fixes an issue in the GraphQLTestClient when using both variables and files together.
Contributed by Etty via PR #1576
Fix crash in Django’s HttpResponse.__repr__ by handling status_code=None in TemporalHttpResponse.__repr__ .
Fix crash in Django’s HttpResponse.repr by handling status_code=None in TemporalHttpResponse.repr .
Contributed by Daniel Hahler via PR #1950
Improve schema directives typing and printing after latest refactor.
Improve schema directives typing and printing after latest refactor.
Support for printing schema directives for non-scalars (e.g. types) and null values.
Also print the schema directive itself and any extra types defined in it
Fix typing for apis expecting directives (e.g. strawberry.field , strawberry.type , etc) to expect an object instead of a StrawberrySchemaDirective , which is now an internal type.
Contributed by Thiago Bellini Ribeiro via PR #1723
Nothing published for this version
This release adds support for Starlette 0.18 to 0.20
This release adds support for Starlette 0.18 to 0.20
It also removes upper bound dependencies limit for starlette, allowing you to install the latest version without having to wait for a new release of Strawberry
Contributed by Timothy Pansino via PR #1594
This release adds a new flask view to allow for aysnc dispatching of requests.
This release adds a new flask view to allow for aysnc dispatching of requests.
This is especially useful when using dataloaders with flask.
from strawberry.flask.views import AsyncGraphQLView
...
app.add_url_rule(
"/graphql" ,
view_func =AsyncGraphQLView.as_view( "graphql_view" , schema =schema, **kwargs),
)
Contributed by Scott Weitzner via PR #1907
This release fixes resolvers using functions with generic type variables raising a MissingTypesForGenericError error.
This release fixes resolvers using functions with generic type variables raising a MissingTypesForGenericError error.
For example a resolver factory like the below can now be used:
import strawberry
from typing import Type, TypeVar
T = TypeVar( "T" ) # or TypeVar("T", bound=StrawberryType) etc
def resolver_factory ( strawberry_type : Type[T]):
def resolver ( id : strawberry.ID) -> T:
return strawberry_type(...)
return resolver
Contributed by Tim OSullivan via PR #1891
Rename internal variable custom_getter in FastAPI router implementation.
Rename internal variable custom_getter in FastAPI router implementation.
Contributed by Gary Donovan via PR #1875
This release adds support for Apollo Federation 2 directives:
This release adds support for Apollo Federation 2 directives:
@shareable
@tag
@override
@inaccessible
This release does not add support for the @link directive.
This release updates the @key directive to align with Apollo Federation 2 updates.
See the below code snippet and/or the newly-added test cases for examples on how to use the new directives. The below snippet demonstrates the @override directive.
import strawberry
from typing import List
@strawberry.interface
class SomeInterface :
id : strawberry.ID
@strawberry.federation.type ( keys =[ "upc" ], extend = True )
class Product ( SomeInterface ):
upc: str = strawberry.federation.field( external = True , override =[ "mySubGraph" ])
@strawberry.federation.type
class Query :
@strawberry.field
def top_products ( self , first : int ) -> List[Product]:
return []
schema = strawberry.federation.Schema( query =Query)
should return:
extend type Product implements SomeInterface @key ( fields : "upc" , resolvable : "True" ) {
id : ID !
upc : String ! @external @override ( from : "mySubGraph" )
}
type Query {
_service : _Service !
_entities ( representations : [ _Any !]!): [ _Entity ]!
topProducts ( first : Int !): [ Product !]!
}
interface SomeInterface {
id : ID !
}
scalar _Any
union _Entity = Product
type _Service {
sdl : String !
}
Contributed by Matt Skillman via PR #1874
Nothing published for this version
Nothing published for this version
This release adds support for passing a custom name to schema directives fields, by using strawberry.directive_field .
This release adds support for passing a custom name to schema directives fields, by using strawberry.directive_field .
import strawberry
@strawberry.schema_directive ( locations =[Location.FIELD_DEFINITION])
class Sensitive :
reason: str = strawberry.directive_field( name = "as" )
real_age_2: str = strawberry.directive_field( name = "real_age" )
@strawberry.type
class Query :
first_name: str = strawberry.field(
directives =[Sensitive( reason = "GDPR" , real_age_2 = "42" )]
)
should return:
type Query {
firstName : String ! @sensitive ( as : "GDPR" , real_age : "42" )
}
Contributed by Patrick Arminio via PR #1871
This release adds support for Mypy 0.950
This release adds support for Mypy 0.950
Contributed by dependabot via PR #1855
Changed the location of UNSET from arguments.py to unset.py . UNSET can now also be imported directly from strawberry . Deprecated the is_unset method…
Changed the location of UNSET from arguments.py to unset.py . UNSET can now also be imported directly from strawberry . Deprecated the is_unset method in favor of the builtin is operator:
from strawberry import UNSET
from strawberry.arguments import is_unset # old
a = UNSET
assert a is UNSET # new
assert is_unset(a) # old
Further more a new subsection to the docs was added explaining this.
Contributed by Dominique Garmier via PR #1813
Fixes a bug when converting pydantic models with NewTypes in a List. This no longers causes an exception.
Fixes a bug when converting pydantic models with NewTypes in a List. This no longers causes an exception.
from typing import List, NewType
from pydantic import BaseModel
import strawberry
password = NewType( "password" , str )
class User ( BaseModel ):
passwords: List[password]
@strawberry.experimental.pydantic.type (User)
class UserType :
passwords: strawberry.auto
Contributed by James Chua via PR #1770
Fixes mypy type inference when using @strawberry.experimental.pydantic.input and @strawberry.experimental.pydantic.interface decorators
Fixes mypy type inference when using @strawberry.experimental.pydantic.input and @strawberry.experimental.pydantic.interface decorators
Contributed by James Chua via PR #1832
Refactoring: Move enum deserialization logic from convert_arguments to CustomGraphQLEnumType
Refactoring: Move enum deserialization logic from convert_arguments to CustomGraphQLEnumType
Contributed by Paulo Costa via PR #1765
Added support for deprecating Enum values with deprecation_reason while using strawberry.enum_value instead of string definition.
Added support for deprecating Enum values with deprecation_reason while using strawberry.enum_value instead of string definition.
@strawberry.enum
class IceCreamFlavour ( Enum ):
VANILLA = strawberry.enum_value( "vanilla" )
STRAWBERRY = strawberry.enum_value( "strawberry" , deprecation_reason = "We ran out" )
CHOCOLATE = "chocolate"
Contributed by Mateusz Sobas via PR #1720
This release fixes an issue in the previous release where requests using query params did not support passing variable values. Variables passed by que
This release fixes an issue in the previous release where requests using query params did not support passing variable values. Variables passed by query params are now parsed from a string to a dictionary.
Contributed by Matt Exact via PR #1820
This release adds support in all our integration for queries via GET requests. This behavior is enabled by default, but you can disable it by passing
This release adds support in all our integration for queries via GET requests. This behavior is enabled by default, but you can disable it by passing allow_queries_via_get=False to the constructor of the integration of your choice.
For security reason only queries are allowed via GET requests.
Contributed by Matt Exact via PR #1686
Correctly parse Decimal scalar types to avoid floating point errors
Correctly parse Decimal scalar types to avoid floating point errors
Contributed by Marco Acierno via PR #1811
Allow all data types in Schema(types=[...])
Allow all data types in Schema(types=[...])
Contributed by Paulo Costa via PR #1714
This release fixes a number of problems with single-result-operations over graphql-transport-ws protocol
This release fixes a number of problems with single-result-operations over graphql-transport-ws protocol
operation IDs now share the same namespace as streaming operations meaning that they cannot be reused while the others are in operation
single-result-operations now run as tasks meaning that messages related to them can be overlapped with other messages on the websocket.
single-result-operations can be cancelled with the complete message.
IDs for single result and streaming result operations are now released once the operation is done, allowing them to be re-used later, as well as freeing up resources related to previous requests.
Contributed by Kristján Valur Jónsson via PR #1792
This release adds an implementation of the GraphQLTestClient for the aiohttp integration (in addition to the existing asgi and Django support). It hid
This release adds an implementation of the GraphQLTestClient for the aiohttp integration (in addition to the existing asgi and Django support). It hides the HTTP request’s details and verifies that there are no errors in the response (this behavior can be disabled 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 strawberry.aiohttp.test.client import GraphQLTestClient
@pytest.fixture
def graphql_client ( aiohttp_client , myapp ):
yield GraphQLTestClient(aiohttp_client(myapp))
And use it everywhere in your tests
def test_strawberry ( graphql_client ):
query = """
query Hi($name: String!) {
hi(name: $name)
}
"""
result = graphql_client.query(query, variables ={ "name" : "🍓" })
assert result.data == { "hi" : "Hi 🍓!" }
Contributed by Etty via PR #1604
This release fixes a bug in the codegen that marked optional unions as non optional.
This release fixes a bug in the codegen that marked optional unions as non optional.
Contributed by Patrick Arminio via PR #1806
This release adds support for passing json_encoder and json_dumps_params to Sanic’s view.
This release adds support for passing json_encoder and json_dumps_params to Sanic’s view.
from strawberry.sanic.views import GraphQLView
from api.schema import Schema
app = Sanic( name )
app.add_route(
GraphQLView.as_view(
schema =schema,
graphiql = True ,
json_encoder =CustomEncoder,
json_dumps_params ={},
),
"/graphql" ,
)
Contributed by Patrick Arminio via PR #1797
Allow use of AsyncIterator and AsyncIterable generics to annotate return type of subscription resolvers.
Allow use of AsyncIterator and AsyncIterable generics to annotate return type of subscription resolvers.
Contributed by San Kilkis via PR #1771
Exeptions from handler functions in graphql_transport_ws are no longer incorrectly caught and classified as message parsing errors.
Exeptions from handler functions in graphql_transport_ws are no longer incorrectly caught and classified as message parsing errors.
Contributed by Kristján Valur Jónsson via PR #1761
Contributed by Guillaume Andreu Sabater via PR #1787
Drop support for Django < 3.2.
Contributed by Guillaume Andreu Sabater via PR #1787
This release adds support for aliased fields when doing codegen.
This release adds support for aliased fields when doing codegen.
Contributed by Patrick Arminio via PR #1772
Add is_auto utility for checking if a type is strawberry.auto , considering the possibility of it being a StrawberryAnnotation or even being used insi
Add is_auto utility for checking if a type is strawberry.auto , considering the possibility of it being a StrawberryAnnotation or even being used inside Annotated .
Contributed by Thiago Bellini Ribeiro via PR #1721
This release moves the console plugin for the codegen command to be last one, allowing to run code before writing files to disk.
This release moves the console plugin for the codegen command to be last one, allowing to run code before writing files to disk.
Contributed by Patrick Arminio via PR #1760
This release adds a python_type to the codegen GraphQLEnum class to allow access to the original python enum when generating code
This release adds a python_type to the codegen GraphQLEnum class to allow access to the original python enum when generating code
Contributed by Patrick Arminio via PR #1752
Fix an issue where there was no clean way to mark a Pydantic field as deprecated, add permission classes, or add directives. Now you can use the short…
Fix an issue where there was no clean way to mark a Pydantic field as deprecated, add permission classes, or add directives. Now you can use the short field syntax to do all three.
import pydantic
import strawberry
class MyModel ( pydantic . BaseModel ):
age: int
name: str
@strawberry.experimental.pydantic.type (MyModel)
class MyType :
age: strawberry.auto
name: strawberry.auto = strawberry.field(
deprecation_reason = "Because" ,
permission_classes =[MyPermission],
directives =[MyDirective],
)
Contributed by Matt Allen via PR #1748
This release adds a missing __init__.py inside cli/commands
This release adds a missing init.py inside cli/commands
Contributed by Patrick Arminio via PR #1751
This release fixes an issue that prevented using generic types with interfaces.
This release fixes an issue that prevented using generic types with interfaces.
Contributed by Patrick Arminio via PR #1701
This release fixes a couple of more issues with codegen:
This release fixes a couple of more issues with codegen:
Adds support for boolean values in input fields
Changes how we unwrap types in order to add full support for LazyTypes, Optionals and Lists
Improve also how we generate types for unions, now we don’t generate a Union type if the selection is for only one type
Contributed by Patrick Arminio via PR #1746
The return type annotation for DataLoader.load and load_many no longer includes any exceptions directly returned by the load_fn . The ability to handl
The return type annotation for DataLoader.load and load_many no longer includes any exceptions directly returned by the load_fn . The ability to handle errors by returning them as elements from load_fn is now documented too.
Contributed by Huon Wilson via PR #1737
Nothing published for this version
Nothing published for this version
This release add supports for LazyType s in the codegen command
This release add supports for LazyType s in the codegen command
Contributed by Patrick Arminio via PR #1745
This release adds support for MyPy 0.941 under Python 3.10
This release adds support for MyPy 0.941 under Python 3.10
Contributed by dependabot via PR #1728
This release adds an experimental codegen feature for queries. It allows to combine a graphql query and Strawberry schema to generate Python types or
This release adds an experimental codegen feature for queries. It allows to combine a graphql query and Strawberry schema to generate Python types or TypeScript types.
You can use the following command:
Terminal window
strawberry codegen --schema schema --output-dir ./output -p python query.graphql
to generate python types that correspond to your GraphQL query.
Contributed by Patrick Arminio via PR #1655
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
Nothing published for this version
This release makes StrawberryOptional and StrawberryList hashable, allowing to use strawberry types with libraries like dacite and dataclasses_json.
This release makes StrawberryOptional and StrawberryList hashable, allowing to use strawberry types with libraries like dacite and dataclasses_json.
Contributed by Patrick Arminio via PR #1726
Add support for postponed evaluation of annotations ( PEP-563 ) to strawberry.Private annotated fields.
Add support for postponed evaluation of annotations ( PEP-563 ) to strawberry.Private annotated fields.
This PR improves the support for scalars when using MyPy.
This PR improves the support for scalars when using MyPy.
Contributed by Patrick Arminio via PR #1205
Added the response object to get_context on the flask view. This means that in fields, something like this can be used;
Added the response object to get_context on the flask view. This means that in fields, something like this can be used;
@strawberry.field
def response_check ( self , info : strawberry.Info) -> bool :
response: Response = info.context[ "response" ]
response.status_code = 401
return True
This release adds support for graphql-transport-ws single result operations.
This release adds support for graphql-transport-ws single result operations.
Single result operations allow clients to execute queries and mutations over an existing WebSocket connection.
Contributed by Jonathan Ehwald PR #1698
One column per quarter.