mirror of
https://github.com/graphql-python/graphene.git
synced 2025-07-22 13:59:51 +03:00
Tweak enum examples
This commit is contained in:
parent
3327ca47c2
commit
0dca8ef1c8
|
@ -61,7 +61,8 @@ you can add description etc. to your enum without changing the original:
|
||||||
|
|
||||||
graphene.Enum.from_enum(
|
graphene.Enum.from_enum(
|
||||||
AlreadyExistingPyEnum,
|
AlreadyExistingPyEnum,
|
||||||
description=lambda v: return 'foo' if v == AlreadyExistingPyEnum.Foo else 'bar')
|
description=lambda v: return 'foo' if v == AlreadyExistingPyEnum.Foo else 'bar'
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
Notes
|
Notes
|
||||||
|
@ -76,6 +77,7 @@ In the Python ``Enum`` implementation you can access a member by initing the Enu
|
||||||
.. code:: python
|
.. code:: python
|
||||||
|
|
||||||
from enum import Enum
|
from enum import Enum
|
||||||
|
|
||||||
class Color(Enum):
|
class Color(Enum):
|
||||||
RED = 1
|
RED = 1
|
||||||
GREEN = 2
|
GREEN = 2
|
||||||
|
@ -89,6 +91,7 @@ However, in Graphene ``Enum`` you need to call get to have the same effect:
|
||||||
.. code:: python
|
.. code:: python
|
||||||
|
|
||||||
from graphene import Enum
|
from graphene import Enum
|
||||||
|
|
||||||
class Color(Enum):
|
class Color(Enum):
|
||||||
RED = 1
|
RED = 1
|
||||||
GREEN = 2
|
GREEN = 2
|
||||||
|
|
Loading…
Reference in New Issue
Block a user