Updated v3 release notes (markdown)

Jonathan Kim 2020-07-11 10:40:46 +01:00
parent 3962c8cf23
commit 97c5114d1b

@ -14,7 +14,54 @@ Graphene builds on top of the excellent [GraphQL-core](https://github.com/graphq
### Better Enum support ### Better Enum support
TODO Graphene v3 introduces better Enum support which should improve the developer experience of working with them in Graphene. Previously when resolving an Enum you had to return the Enum value from the field resolver. In v3 you can now return the Enum member directly:
```python
from graphene import Enum, ObjectType, Schema
class Color(Enum):
RED = 1
GREEN = 2
BLUE = 3
class Query(ObjectType):
color = Color(required=True)
def resolve_color(root, info):
return Color.RED
schema = Schema(query=Query)
result = schema.execute("query { color }")
assert result.data["color"] == "RED"
```
(This change is completely backwards compatible so any resolvers that return the member value will still work)
Also when Enum's are used as an input to a field the resolver now receives the Enum member directly rather than the value:
```python
from graphene import Enum, ObjectType, Schema
class Color(Enum):
RED = 1
GREEN = 2
BLUE = 3
class Query(ObjectType):
color = Color(required=True, color_input=Color(required=True))
def resolve_color(root, info, color_input):
assert color_input is Color.RED
return color_input
schema = Schema(query=Query)
result = schema.execute("query { color(colorInput: RED) }")
assert result.data["color"] == "RED"
```
⚠️ This is a breaking change. You will need to update any resolvers or mutations that accept enums as inputs to support this change. ⚠️
Ref: https://github.com/graphql-python/graphene/pull/1153
### Fast ObjectType creation ### Fast ObjectType creation
@ -43,4 +90,8 @@ TODO
TODO TODO
---
A huge thanks to everyone involved in bringing this release together!
Full changelog https://github.com/graphql-python/graphene/compare/v2.1.8...v3.0.0 Full changelog https://github.com/graphql-python/graphene/compare/v2.1.8...v3.0.0