Skip to content

Commit 81d61f8

Browse files
tompaojkimbo
authored andcommitted
Fix objecttypes DefaultResolver example (#1087) (#1088)
* Create namedtuple as expected * Access result.data instead of result['data'] * Refer to field with camel-case name
1 parent 482c7fc commit 81d61f8

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

docs/types/objecttypes.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ If the :ref:`ResolverParamParent` is a dictionary, the resolver will look for a
212212
213213
from graphene import ObjectType, String, Field, Schema
214214
215-
PersonValueObject = namedtuple('Person', 'first_name', 'last_name')
215+
PersonValueObject = namedtuple('Person', ['first_name', 'last_name'])
216216
217217
class Person(ObjectType):
218218
first_name = String()
@@ -238,10 +238,10 @@ If the :ref:`ResolverParamParent` is a dictionary, the resolver will look for a
238238
}
239239
''')
240240
# With default resolvers we can resolve attributes from an object..
241-
assert result['data']['me'] == {"firstName": "Luke", "lastName": "Skywalker"}
241+
assert result.data['me'] == {"firstName": "Luke", "lastName": "Skywalker"}
242242
243243
# With default resolvers, we can also resolve keys from a dictionary..
244-
assert result['data']['my_best_friend'] == {"firstName": "R2", "lastName": "D2"}
244+
assert result.data['myBestFriend'] == {"firstName": "R2", "lastName": "D2"}
245245
246246
Advanced
247247
~~~~~~~~
@@ -280,7 +280,7 @@ An error will be thrown:
280280
281281
TypeError: resolve_hello() missing 1 required positional argument: 'name'
282282
283-
You can fix this error in serveral ways. Either by combining all keyword arguments
283+
You can fix this error in several ways. Either by combining all keyword arguments
284284
into a dict:
285285
286286
.. code:: python

0 commit comments

Comments
 (0)