strawberry-graphql/strawberry

Do the Lazy-Types support Union?

MaehMaeh opened this issue · 0 comments

If I implement the following construct:

# graphql/file.py

if TYPE_CHECKING:
    from graphql.status import StatusesResult
    

@strawberry.type
class File:
    statuses: Annotated[
        "StatusesResult", strawberry.lazy("graphql.status")
    ]
# graphql/status.py

@strawberry.type
class Status:
    name: str


@strawberry.type
class Statuses:
    statuses: list[Status]


StatusesResult = Annotated[
    Union[Statuses, PermissionProblem],
    strawberry.union("StatusesResult"),
]

I get this error when compiling:

TypeError: File fields cannot be resolved. Unexpected type 'typing.Annotated[typing.Union[graphql.status.Statuses, graphql.problem.PermissionProblem], <strawberry.union.StrawberryUnion object at 0x00000152A836DD10>]'

Have I implemented something incorrectly or is the support simply not yet available?

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.
Fund with Polar