Skip to content

Rename resolve_type method #775

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions docs/types/interfaces.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
2 changes: 1 addition & 1 deletion graphene/types/interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
8 changes: 4 additions & 4 deletions graphene/types/typemap.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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():
Expand Down
2 changes: 1 addition & 1 deletion graphene/types/union.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)