'Using enum value for query result
I am trying to use an Enum in my project with custom strings, something like this:
class Fruit(Enum):
APPLE: "apple"
PEAR: "pear"
BANANA: "banana"
In my query object, I'm trying to use it as follows:
FruitEnum = graphene.Enum.from_enum(Fruit)
class Person(DjangoObjectType):
will_eat_fruit = graphene.List(lambda: FruitEnum)
For a person who will only eat apples, I'd expect to get the result ["apple"] but am instead getting ["APPLE"] and I'm having trouble figuring out how to get graphene to return the enum value while still using enums rather than strings.
Am I missing something?
(Using graphene 2.1.8).
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
