Skip to content
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

Initial fix to consider 'only' optimization for relay #31

Closed
wants to merge 2 commits into from
Closed
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
8 changes: 7 additions & 1 deletion graphene_django_optimizer/query.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from django.db.models import ForeignKey, Prefetch
from django.db.models.constants import LOOKUP_SEP
from graphene import InputObjectType
from graphene.relay.node import GlobalID
from graphene.types.generic import GenericScalar
from graphene.types.resolver import default_resolver
from graphene_django import DjangoObjectType
Expand Down Expand Up @@ -281,7 +282,12 @@ def _is_resolver_for_id_field(self, resolver):
# For python 2 unbound method:
if hasattr(resolve_id, 'im_func'):
resolve_id = resolve_id.im_func
return resolver == resolve_id

if (isinstance(resolver, functools.partial)
and resolver.func == GlobalID.id_resolver):
return resolver.args[0] == resolve_id
else:
return resolver == resolve_id

def _get_model_field_from_name(self, model, name):
try:
Expand Down