Currently to register a GraphQL Enum from an existing enums that resides elsewhere in your code base
you need to do the following ~
from somewhere import MyEnum
MyEnumGQL = strawberry.enum(MyEnum)
@strawberry.type
class Foo:
bar: MyEnumGQL
This results in a pyright error that can be fixed like this
from somewhere import MyEnum
if TYPE_CHECKING:
MyEnumGQL = MyEnum
else:
MyEnumGQL = strawberry.enum(MyEnum)
@strawberry.type
class Foo:
bar: MyEnumGQL
It would be nice if we could just use a default GraphQL implementation of the enum on the fly
so that the strawberry.enum
call would not be needed.
from somewhere import MyEnum
@strawberry.type
class Foo:
bar: MyEnum
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