Skip to content

Commit

Permalink
Fix objecttypes DefaultResolver example (#1087) (#1088)
Browse files Browse the repository at this point in the history
* Create namedtuple as expected
* Access result.data instead of result['data']
* Refer to field with camel-case name
  • Loading branch information
tompao authored and jkimbo committed Dec 26, 2019
1 parent 482c7fc commit 81d61f8
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions docs/types/objecttypes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ If the :ref:`ResolverParamParent` is a dictionary, the resolver will look for a
from graphene import ObjectType, String, Field, Schema
PersonValueObject = namedtuple('Person', 'first_name', 'last_name')
PersonValueObject = namedtuple('Person', ['first_name', 'last_name'])
class Person(ObjectType):
first_name = String()
Expand All @@ -238,10 +238,10 @@ If the :ref:`ResolverParamParent` is a dictionary, the resolver will look for a
}
''')
# With default resolvers we can resolve attributes from an object..
assert result['data']['me'] == {"firstName": "Luke", "lastName": "Skywalker"}
assert result.data['me'] == {"firstName": "Luke", "lastName": "Skywalker"}
# With default resolvers, we can also resolve keys from a dictionary..
assert result['data']['my_best_friend'] == {"firstName": "R2", "lastName": "D2"}
assert result.data['myBestFriend'] == {"firstName": "R2", "lastName": "D2"}
Advanced
~~~~~~~~
Expand Down Expand Up @@ -280,7 +280,7 @@ An error will be thrown:
TypeError: resolve_hello() missing 1 required positional argument: 'name'
You can fix this error in serveral ways. Either by combining all keyword arguments
You can fix this error in several ways. Either by combining all keyword arguments
into a dict:
.. code:: python
Expand Down

0 comments on commit 81d61f8

Please sign in to comment.