From fb64c1941e9ad0a6687d2b6419885543b4200195 Mon Sep 17 00:00:00 2001 From: Jonathan Kim Date: Sat, 11 Jul 2020 10:47:19 +0100 Subject: [PATCH] Updated v3 release notes (markdown) --- v3-release-notes.md | 35 ++++++++++++++++++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) diff --git a/v3-release-notes.md b/v3-release-notes.md index ac19602..7cbb246 100644 --- a/v3-release-notes.md +++ b/v3-release-notes.md @@ -88,7 +88,40 @@ TODO ### 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" +``` ---