From 8fb42148092d53e281c1f58df76843b7681c55ef Mon Sep 17 00:00:00 2001 From: Syrus Akbary Date: Sun, 18 Sep 2016 13:21:02 -0700 Subject: [PATCH] Improved Field args --- graphene/types/field.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/graphene/types/field.py b/graphene/types/field.py index b1122696..531c2f5c 100644 --- a/graphene/types/field.py +++ b/graphene/types/field.py @@ -3,8 +3,9 @@ from collections import Mapping, OrderedDict from functools import partial from ..utils.orderedtype import OrderedType -from .argument import to_arguments +from .argument import Argument, to_arguments from .structures import NonNull +from .unmountedtype import UnmountedType def source_resolver(source, root, args, context, info): @@ -30,6 +31,16 @@ class Field(OrderedType): if required: type = NonNull(type) + # Check if name is actually an argument of the field + if isinstance(name, (Argument, UnmountedType)): + extra_args['name'] = name + name = None + + # Check if source is actually an argument of the field + if isinstance(source, (Argument, UnmountedType)): + extra_args['source'] = source + source = None + self.name = name self._type = type self.args = to_arguments(args or OrderedDict(), extra_args)