mirror of
https://github.com/graphql-python/graphene.git
synced 2025-02-02 20:54:16 +03:00
Isolated unbound function logic in utils
This commit is contained in:
parent
c961f0b3c6
commit
02a6c1c603
|
@ -10,6 +10,7 @@ from graphql.execution.executor import get_default_resolve_type_fn
|
||||||
from graphql.type.typemap import GraphQLTypeMap
|
from graphql.type.typemap import GraphQLTypeMap
|
||||||
|
|
||||||
from ..utils.str_converters import to_camel_case
|
from ..utils.str_converters import to_camel_case
|
||||||
|
from ..utils.get_unbound_function import get_unbound_function
|
||||||
from .dynamic import Dynamic
|
from .dynamic import Dynamic
|
||||||
from .enum import Enum
|
from .enum import Enum
|
||||||
from .inputobjecttype import InputObjectType
|
from .inputobjecttype import InputObjectType
|
||||||
|
@ -251,11 +252,10 @@ class TypeMap(GraphQLTypeMap):
|
||||||
if interface_resolver:
|
if interface_resolver:
|
||||||
break
|
break
|
||||||
resolver = interface_resolver
|
resolver = interface_resolver
|
||||||
|
|
||||||
# Only if is not decorated with classmethod
|
# Only if is not decorated with classmethod
|
||||||
if resolver:
|
if resolver:
|
||||||
if not getattr(resolver, '__self__', True):
|
return get_unbound_function(resolver)
|
||||||
return resolver.__func__
|
|
||||||
return resolver
|
|
||||||
|
|
||||||
return partial(self.default_resolver, name, default_value)
|
return partial(self.default_resolver, name, default_value)
|
||||||
|
|
||||||
|
|
4
graphene/utils/get_unbound_function.py
Normal file
4
graphene/utils/get_unbound_function.py
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
def get_unbound_function(func):
|
||||||
|
if not getattr(func, '__self__', True):
|
||||||
|
return func.__func__
|
||||||
|
return func
|
Loading…
Reference in New Issue
Block a user