Changed type resolver function name to _resolve_type. Fixed #50

This commit is contained in:
Syrus Akbary 2015-11-25 11:33:32 -08:00
parent a0d8b7162a
commit 7340d80fa6
4 changed files with 8 additions and 5 deletions

View File

@ -69,7 +69,7 @@ def test_node_replacedfield():
def test_interface_resolve_type():
resolve_type = Character.resolve_type(schema, Human())
resolve_type = Character._resolve_type(schema, Human())
assert isinstance(resolve_type, GraphQLObjectType)

View File

@ -13,7 +13,10 @@ class Character(Interface):
class Pet(ObjectType):
type = String(resolver=lambda *_: 'Dog')
type = String()
def resolve_type(self, args, info):
return 'Dog'
class Human(Character):

View File

@ -182,7 +182,7 @@ class BaseObjectType(BaseType):
signals.post_init.send(self.__class__, instance=self)
@classmethod
def resolve_type(cls, schema, instance, *args):
def _resolve_type(cls, schema, instance, *args):
return schema.T(instance.__class__)
@classmethod
@ -191,7 +191,7 @@ class BaseObjectType(BaseType):
return GraphQLInterfaceType(
cls._meta.type_name,
description=cls._meta.description,
resolve_type=partial(cls.resolve_type, schema),
resolve_type=partial(cls._resolve_type, schema),
fields=partial(cls.get_fields, schema)
)
elif cls._meta.is_union:

View File

@ -75,7 +75,7 @@ def test_union_cannot_initialize():
def test_interface_resolve_type():
resolve_type = Character.resolve_type(schema, Human(object()))
resolve_type = Character._resolve_type(schema, Human(object()))
assert isinstance(resolve_type, GraphQLObjectType)