Skip to content

Commit c013660

Browse files
committed
Fix example in docstring of GraphQLUnionType (#105)
1 parent 9d9b465 commit c013660

File tree

1 file changed

+7
-13
lines changed

1 file changed

+7
-13
lines changed

src/graphql/type/definition.py

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -922,15 +922,13 @@ class GraphQLUnionType(GraphQLNamedType):
922922
923923
Example::
924924
925-
class PetType(GraphQLUnionType):
926-
name = 'Pet'
927-
types = [DogType, CatType]
928-
929-
def resolve_type(self, value, _type):
930-
if isinstance(value, Dog):
931-
return DogType()
932-
if isinstance(value, Cat):
933-
return CatType()
925+
def resolve_type(obj, _info, _type):
926+
if isinstance(obj, Dog):
927+
return DogType()
928+
if isinstance(obj, Cat):
929+
return CatType()
930+
931+
PetType = GraphQLUnionType('Pet', [DogType, CatType], resolve_type)
934932
"""
935933

936934
resolve_type: Optional[GraphQLTypeResolver]
@@ -947,10 +945,6 @@ def __init__(
947945
ast_node: Optional[UnionTypeDefinitionNode] = None,
948946
extension_ast_nodes: Optional[Collection[UnionTypeExtensionNode]] = None,
949947
) -> None:
950-
"""
951-
952-
:rtype: object
953-
"""
954948
super().__init__(
955949
name=name,
956950
description=description,

0 commit comments

Comments
 (0)