mirror of
https://github.com/graphql-python/graphene.git
synced 2025-06-10 08:33:14 +03:00
Changed type resolver function name to _resolve_type. Fixed #50
This commit is contained in:
parent
a0d8b7162a
commit
7340d80fa6
|
@ -69,7 +69,7 @@ def test_node_replacedfield():
|
||||||
|
|
||||||
|
|
||||||
def test_interface_resolve_type():
|
def test_interface_resolve_type():
|
||||||
resolve_type = Character.resolve_type(schema, Human())
|
resolve_type = Character._resolve_type(schema, Human())
|
||||||
assert isinstance(resolve_type, GraphQLObjectType)
|
assert isinstance(resolve_type, GraphQLObjectType)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -13,7 +13,10 @@ class Character(Interface):
|
||||||
|
|
||||||
|
|
||||||
class Pet(ObjectType):
|
class Pet(ObjectType):
|
||||||
type = String(resolver=lambda *_: 'Dog')
|
type = String()
|
||||||
|
|
||||||
|
def resolve_type(self, args, info):
|
||||||
|
return 'Dog'
|
||||||
|
|
||||||
|
|
||||||
class Human(Character):
|
class Human(Character):
|
||||||
|
|
|
@ -182,7 +182,7 @@ class BaseObjectType(BaseType):
|
||||||
signals.post_init.send(self.__class__, instance=self)
|
signals.post_init.send(self.__class__, instance=self)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def resolve_type(cls, schema, instance, *args):
|
def _resolve_type(cls, schema, instance, *args):
|
||||||
return schema.T(instance.__class__)
|
return schema.T(instance.__class__)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
|
@ -191,7 +191,7 @@ class BaseObjectType(BaseType):
|
||||||
return GraphQLInterfaceType(
|
return GraphQLInterfaceType(
|
||||||
cls._meta.type_name,
|
cls._meta.type_name,
|
||||||
description=cls._meta.description,
|
description=cls._meta.description,
|
||||||
resolve_type=partial(cls.resolve_type, schema),
|
resolve_type=partial(cls._resolve_type, schema),
|
||||||
fields=partial(cls.get_fields, schema)
|
fields=partial(cls.get_fields, schema)
|
||||||
)
|
)
|
||||||
elif cls._meta.is_union:
|
elif cls._meta.is_union:
|
||||||
|
|
|
@ -75,7 +75,7 @@ def test_union_cannot_initialize():
|
||||||
|
|
||||||
|
|
||||||
def test_interface_resolve_type():
|
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)
|
assert isinstance(resolve_type, GraphQLObjectType)
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user