Skip to content
Snippets Groups Projects
Commit 9e52d3e0 authored by Juha Yrjölä's avatar Juha Yrjölä
Browse files

Fix compatibility with newer django-graphene

Newer versions of django-graphene have resolver functions with the
model class as the first argument. Make QueryOptimizer._get_name_from_resolver()
more robust by looking for the first function argument that is either
a string or another partial function.
parent a1ba60b9
No related branches found
No related tags found
No related merge requests found
......@@ -271,7 +271,15 @@ class QueryOptimizer(object):
elif isinstance(resolver, functools.partial):
resolver_fn = resolver
if resolver_fn.func != default_resolver:
resolver_fn = resolver_fn.args[0]
# Some resolvers have the partial function as the second
# argument.
for arg in resolver_fn.args:
if isinstance(arg, (str, functools.partial)):
break
else:
# No suitable instances found, default to first arg
arg = resolver_fn.args[0]
resolver_fn = arg
if isinstance(resolver_fn, functools.partial) and resolver_fn.func == default_resolver:
return resolver_fn.args[0]
return resolver_fn
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment