66from graphql .error import GraphQLError , format_error
77from graphql .execution import execute
88from graphql .language .parser import parse
9- from graphql .type import (GraphQLArgument , GraphQLField ,
9+ from graphql .type import (GraphQLArgument , GraphQLField , GraphQLBoolean ,
1010 GraphQLInputObjectField , GraphQLInputObjectType ,
1111 GraphQLList , GraphQLNonNull , GraphQLObjectType ,
1212 GraphQLScalarType , GraphQLSchema , GraphQLString )
1818 parse_literal = lambda v : 'DeserializedValue' if v .value == 'SerializedValue' else None
1919)
2020
21+
22+ class my_special_dict (dict ):
23+ pass
24+
25+
2126TestInputObject = GraphQLInputObjectType ('TestInputObject' , OrderedDict ([
2227 ('a' , GraphQLInputObjectField (GraphQLString )),
2328 ('b' , GraphQLInputObjectField (GraphQLList (GraphQLString ))),
2429 ('c' , GraphQLInputObjectField (GraphQLNonNull (GraphQLString ))),
2530 ('d' , GraphQLInputObjectField (TestComplexScalar ))
2631]))
2732
33+
34+ TestCustomInputObject = GraphQLInputObjectType ('TestCustomInputObject' , OrderedDict ([
35+ ('a' , GraphQLInputObjectField (GraphQLString )),
36+ ]), container_type = my_special_dict )
37+
2838stringify = lambda obj : json .dumps (obj , sort_keys = True )
2939
3040
@@ -47,6 +57,10 @@ def input_to_json(obj, args, context, info):
4757 GraphQLString ,
4858 args = {'input' : GraphQLArgument (TestInputObject )},
4959 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 )),
5064 'fieldWithNullableStringInput' : GraphQLField (
5165 GraphQLString ,
5266 args = {'input' : GraphQLArgument (GraphQLString )},
@@ -420,6 +434,20 @@ def test_passes_along_null_for_non_nullable_inputs_if_explcitly_set_in_the_query
420434 })
421435
422436
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+
423451def test_allows_lists_to_be_null ():
424452 doc = '''
425453 query q($input: [String]) {
0 commit comments