diff --git a/docs/types/interfaces.rst b/docs/types/interfaces.rst index 21cf21732..05623dbaa 100644 --- a/docs/types/interfaces.rst +++ b/docs/types/interfaces.rst @@ -154,7 +154,7 @@ Interfaces you might come across this error: This happens because Graphene doesn't have enough information to convert the data object into a Graphene type needed to resolve the ``Interface``. To solve -this you can define a ``resolve_type`` class method on the ``Interface`` which +this you can define a ``_resolve_type`` class method on the ``Interface`` which maps a data object to a Graphene type: .. code:: python @@ -164,7 +164,7 @@ maps a data object to a Graphene type: name = graphene.String(required=True) @classmethod - def resolve_type(cls, instance, info): + def _resolve_type(cls, instance, info): if instance.type == 'DROID': return Droid return Human diff --git a/graphene/types/interface.py b/graphene/types/interface.py index dbc3b4760..f8227cdc1 100644 --- a/graphene/types/interface.py +++ b/graphene/types/interface.py @@ -42,7 +42,7 @@ def __init_subclass_with_meta__(cls, _meta=None, **options): super(Interface, cls).__init_subclass_with_meta__(_meta=_meta, **options) @classmethod - def resolve_type(cls, instance, info): + def _resolve_type(cls, instance, info): from .objecttype import ObjectType if isinstance(instance, ObjectType): return type(instance) diff --git a/graphene/types/typemap.py b/graphene/types/typemap.py index b2bc4a0e9..2b8856b0d 100644 --- a/graphene/types/typemap.py +++ b/graphene/types/typemap.py @@ -194,8 +194,8 @@ def construct_interface(self, map, type): return _type _resolve_type = None - if type.resolve_type: - _resolve_type = partial(resolve_type, type.resolve_type, map, + if type._resolve_type: + _resolve_type = partial(resolve_type, type._resolve_type, map, type._meta.name) return GrapheneInterfaceType( graphene_type=type, @@ -216,8 +216,8 @@ def construct_inputobjecttype(self, map, type): def construct_union(self, map, type): _resolve_type = None - if type.resolve_type: - _resolve_type = partial(resolve_type, type.resolve_type, map, + if type._resolve_type: + _resolve_type = partial(resolve_type, type._resolve_type, map, type._meta.name) def types(): diff --git a/graphene/types/union.py b/graphene/types/union.py index 45e03b0c7..d1fab3576 100644 --- a/graphene/types/union.py +++ b/graphene/types/union.py @@ -40,7 +40,7 @@ def get_type(cls): return cls @classmethod - def resolve_type(cls, instance, info): + def _resolve_type(cls, instance, info): from .objecttype import ObjectType # NOQA if isinstance(instance, ObjectType): return type(instance)