django-choices-field
This lib provides integration for enum resolution for Djangoβs TextChoices/IntegerChoices when defining the fields using the django-choices-field lib:
from django.db import modelsfrom django_choices_field import TextChoicesField
class Status(models.TextChoices): ACTIVE = "active", "Is Active" INACTIVE = "inactive", "Inactive"
class Company(models.Model): status = TextChoicesField( choices_enum=Status, default=Status.ACTIVE, )
import strawberryimport strawberry_django
import .models
@strawberry_django.type(models.Company)class Company: status: strawberry.auto
The code above would generate the following schema:
enum Status { ACTIVE INACTIVE}
type Company { status: Status}