mirror of
https://github.com/graphql-python/graphene-django.git
synced 2024-11-26 19:43:43 +03:00
Handle async get_node
This commit is contained in:
parent
1b2d5e02e4
commit
0a84a6ea38
|
@ -265,8 +265,21 @@ def convert_onetoone_field_to_djangomodel(field, registry=None):
|
||||||
_type = registry.get_type_for_model(model)
|
_type = registry.get_type_for_model(model)
|
||||||
if not _type:
|
if not _type:
|
||||||
return
|
return
|
||||||
|
|
||||||
|
class CustomField(Field):
|
||||||
|
def wrap_resolve(self, parent_resolver):
|
||||||
|
resolver = super().wrap_resolve(parent_resolver)
|
||||||
|
|
||||||
return Field(_type, required=not field.null)
|
try:
|
||||||
|
get_running_loop()
|
||||||
|
except RuntimeError:
|
||||||
|
pass
|
||||||
|
else:
|
||||||
|
resolver=sync_to_async(resolver)
|
||||||
|
|
||||||
|
return resolver
|
||||||
|
|
||||||
|
return CustomField(_type, required=not field.null)
|
||||||
|
|
||||||
return Dynamic(dynamic_type)
|
return Dynamic(dynamic_type)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user