Open
Description
openedon Nov 14, 2024
strawberry codegen --schema schema.graphql
generates models referencing postponed types as its class variable instead of using a string to be deferred.
Describe the Bug
From schema, the following code has been generated. In this example, AccessCredentialFilter is referencing itself inside the model
@strawberry.input
class AccessCredentialFilter:
and_: list[AccessCredentialFilter | None] | None = strawberry.field(name="and")
However, it should rather be
@strawberry.input
class AccessCredentialFilter:
and_: list[Union["AccessCredentialFilter", None]] | None = strawberry.field(name="and")
or
@strawberry.input
class AccessCredentialFilter:
and_: list[Optional["AccessCredentialFilter"]] | None = strawberry.field(name="and")
System Information
- Operating system: Ubuntu 22.04
- Strawberry version (if applicable): 0.248.1
Additional Context
It seems there was a related discussion: #769
but not sure if it was discussed in the context of codegen.
I'd be happy to contribute if I can be directed to the right part of the code.
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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment