From 61ab8ab8544b08c9fda6d59d8c564128379febab Mon Sep 17 00:00:00 2001 From: Jonathan Kim Date: Sat, 11 Jul 2020 11:05:20 +0100 Subject: [PATCH] Updated v3 release notes (markdown) --- v3-release-notes.md | 53 +++++++++++++++++++++++++++++++++++++-------- 1 file changed, 44 insertions(+), 9 deletions(-) diff --git a/v3-release-notes.md b/v3-release-notes.md index 7cbb246..835163e 100644 --- a/v3-release-notes.md +++ b/v3-release-notes.md @@ -61,22 +61,21 @@ 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 - -TODO - -### Base64 scalar - -TODO +Reference: https://github.com/graphql-python/graphene/pull/1153 ### Subscription support TODO +### Fast ObjectType creation + +In Graphene v3 optimises the ObjectType initialization resulting in a x3 speed up! It does this by leveraging the same strategy that dataclasses introduced (dynamic creation of optimal `__init__` functions based on eval). + +More info here: https://github.com/graphql-python/graphene/pull/1157 + ### Other new features +* Add a new Base64 scalar type (https://github.com/graphql-python/graphene/pull/1221) * Better error messages when relay `global_id` fails to parse (https://github.com/graphql-python/graphene/pull/1074) * Graphene now accepts plain GraphQL types as well as Graphene types (https://github.com/graphql-python/graphene/pull/1224) @@ -123,6 +122,42 @@ result = schema.execute("query { color(colorInput: RED) }") assert result.data["color"] == "EnumMeta.RED" ``` +### ObjectType private fields + +Previously you ObjectType's could be initialized with private variables by prepending the variable name with an `_`. This is no longer possible in v3 without defining a custom `__init__` function on the `ObjectType`. + +Before: + +```python +from graphene import ObjectType, String + +class User(ObjectType): + _private_state = None + + name = String() + +user = User(name="Leia", _private_state="Extra info") +assert user._private_state == "Extra info" +``` + +After: + +```python +from graphene import ObjectType, String + +class User(ObjectType): + def __init__(self, _private_state=None, **kwargs): + self._private_state = _private_state + super().__init__(**kwargs) + + _private_state = None + + name = String() + +user = User(name="Leia", _private_state="Extra info") +assert user._private_state == "Extra info" +``` + --- A huge thanks to everyone involved in bringing this release together!