Skip to content

Commit

Permalink
Pull sync thread higher
Browse files Browse the repository at this point in the history
  • Loading branch information
jaw9c committed May 5, 2023
1 parent 19e4add commit 05e266a
Showing 1 changed file with 13 additions and 30 deletions.
43 changes: 13 additions & 30 deletions graphene_django/fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -260,46 +260,29 @@ def connection_resolver(

iterable = resolver(root, info, **args)

if info.is_awaitable(iterable):

async def resolve_connection_async(iterable):
iterable = await iterable
if iterable is None:
iterable = default_manager

iterable = await sync_to_async(queryset_resolver)(
connection, iterable, info, args
)

if info.is_awaitable(iterable):
iterable = await iterable

return await sync_to_async(cls.resolve_connection)(
connection, args, iterable, max_limit=max_limit
)

return resolve_connection_async(iterable)

if iterable is None:
iterable = default_manager

iterable = queryset_resolver(connection, iterable, info, args)

return cls.resolve_connection(connection, args, iterable, max_limit=max_limit)

def wrap_resolve(self, parent_resolver):
try:
get_running_loop()
except RuntimeError:
pass
else:
iterable = sync_to_async(queryset_resolver)(
connection, iterable, info, args
)
return sync_to_async(cls.resolve_connection)(
connection, args, iterable, max_limit=max_limit
return partial(
sync_to_async(self.connection_resolver),
parent_resolver,
self.connection_type,
self.get_manager(),
self.get_queryset_resolver(),
self.max_limit,
self.enforce_first_or_last,
)

iterable = queryset_resolver(connection, iterable, info, args)

return cls.resolve_connection(connection, args, iterable, max_limit=max_limit)

def wrap_resolve(self, parent_resolver):
return partial(
self.connection_resolver,
parent_resolver,
Expand Down

0 comments on commit 05e266a

Please sign in to comment.