mirror of
https://github.com/graphql-python/graphene-django.git
synced 2025-02-22 06:20:33 +03:00
improve async detection
This commit is contained in:
parent
791209f557
commit
b69476f50f
|
@ -80,7 +80,9 @@ class DjangoSyncRequiredMiddleware:
|
|||
if hasattr(parent_type, "graphene_type") and hasattr(
|
||||
parent_type.graphene_type._meta, "model"
|
||||
):
|
||||
if not inspect.iscoroutinefunction(next):
|
||||
if not inspect.iscoroutinefunction(next) and not inspect.isasyncgenfunction(
|
||||
next
|
||||
):
|
||||
return sync_to_async(next)(root, info, **args)
|
||||
|
||||
## In addition, if we're resolving to a DjangoObject type
|
||||
|
@ -88,7 +90,9 @@ class DjangoSyncRequiredMiddleware:
|
|||
if hasattr(info.return_type, "graphene_type") and hasattr(
|
||||
info.return_type.graphene_type._meta, "model"
|
||||
):
|
||||
if not info.is_awaitable(next):
|
||||
if not inspect.iscoroutinefunction(next) and not inspect.isasyncgenfunction(
|
||||
next
|
||||
):
|
||||
return sync_to_async(next)(root, info, **args)
|
||||
|
||||
return next(root, info, **args)
|
||||
|
|
|
@ -266,11 +266,10 @@ class DjangoConnectionField(ConnectionField):
|
|||
iterable = await iterable
|
||||
if iterable is None:
|
||||
iterable = default_manager
|
||||
## This could also be async
|
||||
iterable = queryset_resolver(connection, iterable, info, args)
|
||||
|
||||
if info.is_awaitable(iterable):
|
||||
iterable = await iterable
|
||||
iterable = await sync_to_async(queryset_resolver)(
|
||||
connection, iterable, info, args
|
||||
)
|
||||
|
||||
return await sync_to_async(cls.resolve_connection)(
|
||||
connection, args, iterable, max_limit=max_limit
|
||||
|
|
Loading…
Reference in New Issue
Block a user