You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This code raises the following exception: TypeError: Response fields cannot be resolved. Unexpected type 'typing.Annotated[typing.Union[__main__.User, __main__.ProUser], <strawberry.union.StrawberryUnion object at 0x14f8a90>]'
But if you replace GeneralUser = Annotated[Union[User, ProUser], strawberry.union("GeneralUser")] with GeneralUser = strawberry.union("GeneralUser", (User, ProUser)) the code works as expected and doesn't raise any exception.
It looks like union types cannot be applied to generic types if they're declared with Annotated, because this bug isn't reproducible in case the old-style approach with strawberry.union is used.
System Information
Strawberry version (if applicable): 0.216.1
Python version: 3.9
Upvote & Fund
We're using Polar.sh so you can upvote and help fund this issue.
We receive the funding once the issue is completed & confirmed by you.
Thank you in advance for helping prioritize & fund our backlog.
The text was updated successfully, but these errors were encountered:
Hello! I tried to create a type inheriting a generic type with a union type applied and caught a
TypeError: Response fields cannot be resolved.
Describe the Bug
There's a code fragment the bug can be reproduced with:
This code raises the following exception:
TypeError: Response fields cannot be resolved. Unexpected type 'typing.Annotated[typing.Union[__main__.User, __main__.ProUser], <strawberry.union.StrawberryUnion object at 0x14f8a90>]'
But if you replace
GeneralUser = Annotated[Union[User, ProUser], strawberry.union("GeneralUser")]
withGeneralUser = strawberry.union("GeneralUser", (User, ProUser))
the code works as expected and doesn't raise any exception.It looks like union types cannot be applied to generic types if they're declared with
Annotated
, because this bug isn't reproducible in case the old-style approach withstrawberry.union
is used.System Information
Upvote & Fund
The text was updated successfully, but these errors were encountered: