Reusing the types from the DjangoObjectType in the graphene
I have created the PreferencesNode from the DjangoObjectType which contains the gateway provider as TextChoices.
class GatewayProvider(models.TextChoices):
STRIPE = "stripe", "Stripe"
RAZORPAY = "razorpay", "Razorpay"
class PreferencesNode(DjangoObjectType):
class Meta:
model = Preferences
exclude_fields = ("user_id",)
Now I want to use AccountPreferencesGatewayProviderChoices enum (created via PreferencesNode). How can I do this?
Currently I am creating another enum inheriting graphene.Enum.
class GatewayProviderEnum(graphene.Enum):
STRIPE = GatewayProvider.STRIPE.value
RAZORPAY = GatewayProvider.RAZORPAY.value
But this is creating redundant enum type.
