From 7340d80fa64d4aa815300322de5a9c5b25c394c3 Mon Sep 17 00:00:00 2001 From: Syrus Akbary Date: Wed, 25 Nov 2015 11:33:32 -0800 Subject: [PATCH] Changed type resolver function name to _resolve_type. Fixed #50 --- graphene/contrib/django/tests/test_types.py | 2 +- graphene/core/tests/test_query.py | 5 ++++- graphene/core/types/objecttype.py | 4 ++-- graphene/core/types/tests/test_objecttype.py | 2 +- 4 files changed, 8 insertions(+), 5 deletions(-) diff --git a/graphene/contrib/django/tests/test_types.py b/graphene/contrib/django/tests/test_types.py index 5d7f582e..4d709580 100644 --- a/graphene/contrib/django/tests/test_types.py +++ b/graphene/contrib/django/tests/test_types.py @@ -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) diff --git a/graphene/core/tests/test_query.py b/graphene/core/tests/test_query.py index b9e8ee84..5fbe2faa 100644 --- a/graphene/core/tests/test_query.py +++ b/graphene/core/tests/test_query.py @@ -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): diff --git a/graphene/core/types/objecttype.py b/graphene/core/types/objecttype.py index 14283af5..09f65ad0 100644 --- a/graphene/core/types/objecttype.py +++ b/graphene/core/types/objecttype.py @@ -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: diff --git a/graphene/core/types/tests/test_objecttype.py b/graphene/core/types/tests/test_objecttype.py index add37bae..6bb157d6 100644 --- a/graphene/core/types/tests/test_objecttype.py +++ b/graphene/core/types/tests/test_objecttype.py @@ -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)