From ccd8349ef61c96f5f23622e706afb3c14fe12be2 Mon Sep 17 00:00:00 2001 From: Syrus Akbary Date: Sat, 18 Jun 2016 14:32:53 -0700 Subject: [PATCH] Added as_field utility --- graphene/utils/as_field.py | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 graphene/utils/as_field.py diff --git a/graphene/utils/as_field.py b/graphene/utils/as_field.py new file mode 100644 index 00000000..59d02426 --- /dev/null +++ b/graphene/utils/as_field.py @@ -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))