From caf6e506a5571f1406524e8e56bee5914688d5bb Mon Sep 17 00:00:00 2001 From: sarath Date: Sun, 7 Feb 2021 22:52:42 +0530 Subject: [PATCH] Root Value example doesn't work #1303 --- docs/execution/execute.rst | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/docs/execution/execute.rst b/docs/execution/execute.rst index 23be0b42..7f282dd9 100644 --- a/docs/execution/execute.rst +++ b/docs/execution/execute.rst @@ -76,13 +76,22 @@ Value used for :ref:`ResolverParamParent` in root queries and mutations can be o .. code:: python - from graphene import ObjectType, Field, Schema + from graphene import ObjectType, Field, Schema, String, ID + + + class User(ObjectType): + id = ID() + name = String() + first_name = String() + last_name = String() + class Query(ObjectType): - me = Field(User) + user = Field(User) def resolve_user(root, info): - return {'id': root.id, 'firstName': root.name} + return User(id=root.id, first_name=root.name) + schema = Schema(Query) user_root = User(id=12, name='bob') @@ -98,7 +107,8 @@ Value used for :ref:`ResolverParamParent` in root queries and mutations can be o ''', root=user_root ) - assert result.data['user']['id'] == user_root.id + assert result.data['user']['id'] == str(user_root.id) + Operation Name ______________