graphql-python / graphql-python/graphene-django

enumValues not populated for Django CharFields with choices

Đang mở
#1,069 0 bình luận 0 reaction 0 người được giao Xem trên GitHub
🐛bug
Ngôn ngữ chính
Python
Star
4.4k
Fork
760
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Mô tả

**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.

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.