mirror of
https://github.com/graphql-python/graphene-django.git
synced 2025-02-22 14:30:33 +03:00
Handle custom Djangoconnectionresolvers
This commit is contained in:
parent
b69476f50f
commit
b134ab0a3e
|
@ -95,4 +95,15 @@ class DjangoSyncRequiredMiddleware:
|
|||
):
|
||||
return sync_to_async(next)(root, info, **args)
|
||||
|
||||
## We also need to handle custom resolvers around Connections
|
||||
# but only when their parent is not already a DjangoObject type
|
||||
# this case already gets handled above.
|
||||
if hasattr(info.return_type, "graphene_type"):
|
||||
if hasattr(info.return_type.graphene_type, "Edge"):
|
||||
node_type = info.return_type.graphene_type.Edge.node.type
|
||||
if hasattr(node_type, "_meta") and hasattr(node_type._meta, "model"):
|
||||
if not inspect.iscoroutinefunction(
|
||||
next
|
||||
) and not inspect.isasyncgenfunction(next):
|
||||
return sync_to_async(next)(root, info, **args)
|
||||
return next(root, info, **args)
|
||||
|
|
Loading…
Reference in New Issue
Block a user