diff --git a/graphene/types/argument.py b/graphene/types/argument.py index 49784b10..ead2c005 100644 --- a/graphene/types/argument.py +++ b/graphene/types/argument.py @@ -3,6 +3,7 @@ from itertools import chain from ..utils.orderedtype import OrderedType from .structures import NonNull +from .dynamic import Dynamic class Argument(OrderedType): @@ -33,6 +34,9 @@ def to_arguments(args, extra_args): iter_arguments = chain(args.items(), extra_args) arguments = OrderedDict() for default_name, arg in iter_arguments: + if isinstance(arg, Dynamic): + arg = arg.get_type() + if isinstance(arg, UnmountedType): arg = arg.Argument() diff --git a/graphene/types/tests/test_mutation.py b/graphene/types/tests/test_mutation.py index 2af6f4fd..24096161 100644 --- a/graphene/types/tests/test_mutation.py +++ b/graphene/types/tests/test_mutation.py @@ -4,6 +4,7 @@ from ..mutation import Mutation from ..objecttype import ObjectType from ..schema import Schema from ..scalars import String +from ..dynamic import Dynamic def test_generate_mutation_no_args(): @@ -47,12 +48,15 @@ def test_mutation_execution(): class CreateUser(Mutation): class Input: name = String() + dynamic = Dynamic(lambda: String()) name = String() + dynamic = Dynamic(lambda: String()) def mutate(self, args, context, info): name = args.get('name') - return CreateUser(name=name) + dynamic = args.get('dynamic') + return CreateUser(name=name, dynamic=dynamic) class Query(ObjectType): a = String() @@ -62,14 +66,16 @@ def test_mutation_execution(): schema = Schema(query=Query, mutation=MyMutation) result = schema.execute(''' mutation mymutation { - createUser(name:"Peter") { + createUser(name:"Peter", dynamic: "dynamic") { name + dynamic } } ''') assert not result.errors assert result.data == { 'createUser': { - 'name': "Peter" + 'name': 'Peter', + 'dynamic': 'dynamic', } }