graphql-python / graphql-python/graphene-django
enumValues not populated for Django CharFields with choices
- Vorherrschende Sprache
- Python
- Sterne
- 4.4k
- Forks
- 760
- PR-Merge-Kennzahlen
- Keine gemergten PRs in 30 T.
Beschreibung
**Note: for support questions, please use stackoverflow**. This repository's issues are reserved for feature requests and bug reports.
* **What is the current behavior?**
Querying the field types of a node that has an enum field, returns that field without enumValues.
* **If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem** via
a github repo, https://repl.it or similar (you can use this template as a starting point: https://repl.it/@jkimbo/Graphene-Django-Example).
[https://repl.it/@moritz89/Graphene-Django-Example#recipes/schema.py](https://repl.it/@moritz89/Graphene-Django-Example#recipes/schema.py)
P.S. The template seems to have a broken import of `DjangoFilterConnectionField`
* **What is the expected behavior?**
When querying the types with
```
{
__type(name: "RecipeIngredientType") {
name,
fields {
name,
__typename,
type {
name,
description,
enumValues {
name,
description
}
},
}
}
}
```
The enumValues field for the unit field should be populated with the enum values
```
{
"data": {
"__type": {
"name": "RecipeIngredientType",
"fields": [
...
{
"name": "unit",
"__typename": "__Field",
"type": {
"name": null,
"description": null,
"enumValues": null
}
}
]
}
}
}
```
* **What is the motivation / use case for changing the behavior?**
The use case is to populate a UI of a frontend with the possible choices.
* **Please tell us about your environment:**
The version as in the Poetry.lock of the above repl. This behavior can also be reproduced with Django 3.1 and 2.2 with graphene-django at 2.13.0.
* **Other information** (e.g. detailed explanation, stacktraces, related issues, suggestions how to fix, links for us to have context, eg. stackoverflow)
There exist workarounds, for example `unit = graphene.Field(graphene.Enum.from_enum(RecipeIngredient.Unit))` where the choices are defined in a Django models.TextChoices enum class.
Beitragsleitfaden
Bewertung
Dieses Issue wurde noch nicht bewertet.