File tree Expand file tree Collapse file tree 2 files changed +13
-3
lines changed Expand file tree Collapse file tree 2 files changed +13
-3
lines changed Original file line number Diff line number Diff line change 3
3
4
4
from ..utils .orderedtype import OrderedType
5
5
from .structures import NonNull
6
+ from .dynamic import Dynamic
6
7
7
8
8
9
class Argument (OrderedType ):
@@ -33,6 +34,9 @@ def to_arguments(args, extra_args):
33
34
iter_arguments = chain (args .items (), extra_args )
34
35
arguments = OrderedDict ()
35
36
for default_name , arg in iter_arguments :
37
+ if isinstance (arg , Dynamic ):
38
+ arg = arg .get_type ()
39
+
36
40
if isinstance (arg , UnmountedType ):
37
41
arg = arg .Argument ()
38
42
Original file line number Diff line number Diff line change 4
4
from ..objecttype import ObjectType
5
5
from ..schema import Schema
6
6
from ..scalars import String
7
+ from ..dynamic import Dynamic
7
8
8
9
9
10
def test_generate_mutation_no_args ():
@@ -47,12 +48,15 @@ def test_mutation_execution():
47
48
class CreateUser (Mutation ):
48
49
class Input :
49
50
name = String ()
51
+ dynamic = Dynamic (lambda : String ())
50
52
51
53
name = String ()
54
+ dynamic = Dynamic (lambda : String ())
52
55
53
56
def mutate (self , args , context , info ):
54
57
name = args .get ('name' )
55
- return CreateUser (name = name )
58
+ dynamic = args .get ('dynamic' )
59
+ return CreateUser (name = name , dynamic = dynamic )
56
60
57
61
class Query (ObjectType ):
58
62
a = String ()
@@ -62,14 +66,16 @@ class MyMutation(ObjectType):
62
66
63
67
schema = Schema (query = Query , mutation = MyMutation )
64
68
result = schema .execute (''' mutation mymutation {
65
- createUser(name:"Peter") {
69
+ createUser(name:"Peter", dynamic: "dynamic" ) {
66
70
name
71
+ dynamic
67
72
}
68
73
}
69
74
''' )
70
75
assert not result .errors
71
76
assert result .data == {
72
77
'createUser' : {
73
- 'name' : "Peter"
78
+ 'name' : 'Peter' ,
79
+ 'dynamic' : 'dynamic' ,
74
80
}
75
81
}
You can’t perform that action at this time.
0 commit comments