It would be nice to rename generic types by annotating them.
E.g. with typing.Annotated
like for arguments.
My use case is to annotate generic types inside the union:
import strawberry
import typing as tp
GenericType = tp.TypeVar('GenericType')
@strawberry.type(name='SomeGeneric')
class SomeGenericType(
tp.Generic[GenericType]
):
value: GenericType
SomeType = strawberry.union(
name='SomeTypeName',
types=(
tp.Annotated[SomeGenericType[int], strawberry.type(name='SomeGenericTypeInt')],
tp.Annotated[SomeGenericType[float], strawberry.type(name='SomeGenericTypeFloat')],
)
)
@strawberry.type
class Query:
@strawberry.field
def user(self) -> tp.Optional[SomeType]:
return None
schema = strawberry.Schema(query=Query)
Pay now to fund the work behind this issue.
Get updates on progress being made.
Maintainer is rewarded once the issue is completed.
You're funding impactful open source efforts
You want to contribute to this effort
You want to get funding like this too