6
6
from graphql .error import GraphQLError , format_error
7
7
from graphql .execution import execute
8
8
from graphql .language .parser import parse
9
- from graphql .type import (GraphQLArgument , GraphQLField ,
9
+ from graphql .type import (GraphQLArgument , GraphQLField , GraphQLBoolean ,
10
10
GraphQLInputObjectField , GraphQLInputObjectType ,
11
11
GraphQLList , GraphQLNonNull , GraphQLObjectType ,
12
12
GraphQLScalarType , GraphQLSchema , GraphQLString )
18
18
parse_literal = lambda v : 'DeserializedValue' if v .value == 'SerializedValue' else None
19
19
)
20
20
21
+
22
+ class my_special_dict (dict ):
23
+ pass
24
+
25
+
21
26
TestInputObject = GraphQLInputObjectType ('TestInputObject' , OrderedDict ([
22
27
('a' , GraphQLInputObjectField (GraphQLString )),
23
28
('b' , GraphQLInputObjectField (GraphQLList (GraphQLString ))),
24
29
('c' , GraphQLInputObjectField (GraphQLNonNull (GraphQLString ))),
25
30
('d' , GraphQLInputObjectField (TestComplexScalar ))
26
31
]))
27
32
33
+
34
+ TestCustomInputObject = GraphQLInputObjectType ('TestCustomInputObject' , OrderedDict ([
35
+ ('a' , GraphQLInputObjectField (GraphQLString )),
36
+ ]), container_type = my_special_dict )
37
+
28
38
stringify = lambda obj : json .dumps (obj , sort_keys = True )
29
39
30
40
@@ -47,6 +57,10 @@ def input_to_json(obj, args, context, info):
47
57
GraphQLString ,
48
58
args = {'input' : GraphQLArgument (TestInputObject )},
49
59
resolver = input_to_json ),
60
+ 'fieldWithCustomObjectInput' : GraphQLField (
61
+ GraphQLBoolean ,
62
+ args = {'input' : GraphQLArgument (TestCustomInputObject )},
63
+ resolver = lambda root , args , context , info : isinstance (args .get ('input' ), my_special_dict )),
50
64
'fieldWithNullableStringInput' : GraphQLField (
51
65
GraphQLString ,
52
66
args = {'input' : GraphQLArgument (GraphQLString )},
@@ -420,6 +434,20 @@ def test_passes_along_null_for_non_nullable_inputs_if_explcitly_set_in_the_query
420
434
})
421
435
422
436
437
+ def test_uses_objectinput_container ():
438
+ doc = '''
439
+ {
440
+ fieldWithCustomObjectInput(input: {a: "b"})
441
+ }
442
+ '''
443
+
444
+ check (doc , {
445
+ 'data' : {
446
+ 'fieldWithCustomObjectInput' : True
447
+ }
448
+ })
449
+
450
+
423
451
def test_allows_lists_to_be_null ():
424
452
doc = '''
425
453
query q($input: [String]) {
0 commit comments