mirror of
https://github.com/graphql-python/graphene.git
synced 2024-11-28 20:43:57 +03:00
Updated v3 release notes (markdown)
parent
97c5114d1b
commit
fb64c1941e
|
@ -88,7 +88,40 @@ TODO
|
||||||
|
|
||||||
### Enum inputs
|
### Enum inputs
|
||||||
|
|
||||||
TODO
|
As outlined above: if a field takes an Enum as an input the resolver will now get passed the Enum member rather than the member value.
|
||||||
|
|
||||||
|
For example, given the following schema:
|
||||||
|
|
||||||
|
```python
|
||||||
|
from graphene import Enum, ObjectType, String, Schema
|
||||||
|
|
||||||
|
class Color(Enum):
|
||||||
|
RED = 1
|
||||||
|
GREEN = 2
|
||||||
|
BLUE = 3
|
||||||
|
|
||||||
|
class Query(ObjectType):
|
||||||
|
color = String(color_input=Color(required=True))
|
||||||
|
|
||||||
|
def resolve_color(root, info, color_input):
|
||||||
|
return color_input
|
||||||
|
|
||||||
|
schema = Schema(query=Query)
|
||||||
|
```
|
||||||
|
|
||||||
|
Before:
|
||||||
|
|
||||||
|
```python
|
||||||
|
result = schema.execute("query { color(colorInput: RED) }")
|
||||||
|
assert result.data["color"] == "1"
|
||||||
|
```
|
||||||
|
|
||||||
|
After:
|
||||||
|
|
||||||
|
```python
|
||||||
|
result = schema.execute("query { color(colorInput: RED) }")
|
||||||
|
assert result.data["color"] == "EnumMeta.RED"
|
||||||
|
```
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user