graphql-python / graphql-python/graphene-django

IntegerChoices does not output correct Enum

Open
#990 4 comments 10 reactions 0 assignees View on GitHub
✨enhancement
Dominant language
Python
Stars
4.4k
Forks
760
PR merge metrics
No merged PRs in 30d

Description

When generating a schema from a model that has as a field of type `IntegerChoices` https://docs.djangoproject.com/en/3.0/ref/models/fields/#choices), the choices are not displayed in the schema

* **What is the current behavior?**
```python
from django.db import models
from graphene_django.types import DjangoObjectType

# Model
class ExampleModel(models.Model):
class Answer(models.IntegerChoices):
NO = 0
YES = 1

#Schema
class ExampleType(DjangoObjectType):
class Meta:
model = ExampleModel
```

When generating the schema with `./manage.py graphql_schema --schema example_app.schema.root_schema --out schema.graphql` the output looks like this

```graphql
enum ExampleType {
A_0
A_1
}
```

`YES` and `NO` are not displayed in the enum

* **What is the expected behavior?**

`YES` and `NO` are displayed in the enum
```graphql
enum ExampleType {
YES
NO
}
```

* **What is the motivation / use case for changing the behavior?**

* **Please tell us about your environment:**

- Version:
Python 3.7
graphene-django==2.10.1
graphene==2.1.8
Django==3.0.6
- Platform:
MacOs

* **Other information** (e.g. detailed explanation, stacktraces, related issues, suggestions how to fix, links for us to have context, eg. stackoverflow)

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.