mirror of
https://github.com/graphql-python/graphene.git
synced 2024-11-11 04:07:16 +03:00
Added as_field utility
This commit is contained in:
parent
3c2f2c3c06
commit
ccd8349ef6
10
graphene/utils/as_field.py
Normal file
10
graphene/utils/as_field.py
Normal file
|
@ -0,0 +1,10 @@
|
|||
from ..types.field import Field
|
||||
from ..types.unmountedtype import UnmountedType
|
||||
|
||||
|
||||
def as_field(value):
|
||||
if isinstance(value, UnmountedType):
|
||||
return value.as_field()
|
||||
elif isinstance(value, Field):
|
||||
return value
|
||||
raise Exception("{} is not a field".format(value))
|
Loading…
Reference in New Issue
Block a user