mirror of
https://github.com/graphql-python/graphene.git
synced 2025-02-23 15:10:48 +03:00
Improved support for promise-like connections
This commit is contained in:
parent
3fa65aa343
commit
e6733d56b2
|
@ -5,7 +5,7 @@ from functools import partial
|
||||||
import six
|
import six
|
||||||
|
|
||||||
from graphql_relay import connection_from_list
|
from graphql_relay import connection_from_list
|
||||||
from promise import Promise
|
from promise import Promise, is_thenable, promisify
|
||||||
|
|
||||||
from ..types import (AbstractType, Boolean, Enum, Int, Interface, List, NonNull, Scalar, String,
|
from ..types import (AbstractType, Boolean, Enum, Int, Interface, List, NonNull, Scalar, String,
|
||||||
Union)
|
Union)
|
||||||
|
@ -140,8 +140,8 @@ class ConnectionField(Field):
|
||||||
return resolved
|
return resolved
|
||||||
|
|
||||||
on_resolve = partial(connection_type.connection_resolver, args=args, context=context, info=info)
|
on_resolve = partial(connection_type.connection_resolver, args=args, context=context, info=info)
|
||||||
if isinstance(resolved, Promise):
|
if is_thenable(resolved):
|
||||||
return resolved.then(on_resolve)
|
return promisify(resolved).then(on_resolve)
|
||||||
|
|
||||||
return on_resolve(resolved)
|
return on_resolve(resolved)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user