Name | Modified | Size | Downloads / Week |
---|---|---|---|
Parent folder | |||
strawberry_graphql-0.277.1-py3-none-any.whl | 2025-07-19 | 308.9 kB | |
strawberry_graphql-0.277.1.tar.gz | 2025-07-19 | 211.6 kB | |
0.277.1 source code.tar.gz | 2025-07-19 | 1.2 MB | |
0.277.1 source code.zip | 2025-07-19 | 1.6 MB | |
README.md | 2025-07-19 | 953 Bytes | |
Totals: 5 Items | 3.3 MB | 0 |
This release fixes the resolution of Generics
when specializing using a union
defined with Annotated
, like in the example below:
:::python
from typing import Annotated, Generic, TypeVar, Union
import strawberry
T = TypeVar("T")
@strawberry.type
class User:
name: str
age: int
@strawberry.type
class ProUser:
name: str
age: float
@strawberry.type
class GenType(Generic[T]):
data: T
GeneralUser = Annotated[Union[User, ProUser], strawberry.union("GeneralUser")]
@strawberry.type
class Response(GenType[GeneralUser]): ...
@strawberry.type
class Query:
@strawberry.field
def user(self) -> Response: ...
schema = strawberry.Schema(query=Query)
Before this would raise a TypeError
, now it works as expected.
Releases contributed by @bellini666 via [#3950]