File tree Expand file tree Collapse file tree 2 files changed +10
-6
lines changed Expand file tree Collapse file tree 2 files changed +10
-6
lines changed Original file line number Diff line number Diff line change 11import json
2+ from collections import OrderedDict
23
34from pytest import raises
45
1718 parse_literal = lambda v : 'DeserializedValue' if v .value == 'SerializedValue' else None
1819)
1920
20- TestInputObject = GraphQLInputObjectType ('TestInputObject' , {
21- 'a' : GraphQLInputObjectField (GraphQLString ),
22- 'b' : GraphQLInputObjectField (GraphQLList (GraphQLString )),
23- 'c' : GraphQLInputObjectField (GraphQLNonNull (GraphQLString )),
24- 'd' : GraphQLInputObjectField (TestComplexScalar )
25- } )
21+ TestInputObject = GraphQLInputObjectType ('TestInputObject' , OrderedDict ([
22+ ( 'a' , GraphQLInputObjectField (GraphQLString ) ),
23+ ( 'b' , GraphQLInputObjectField (GraphQLList (GraphQLString ) )),
24+ ( 'c' , GraphQLInputObjectField (GraphQLNonNull (GraphQLString ) )),
25+ ( 'd' , GraphQLInputObjectField (TestComplexScalar ) )
26+ ]) )
2627
2728stringify = lambda obj : json .dumps (obj , sort_keys = True )
2829
Original file line number Diff line number Diff line change @@ -522,6 +522,9 @@ def _define_field_map(self):
522522 if callable (fields ):
523523 fields = fields ()
524524
525+ if not isinstance (fields , OrderedDict ):
526+ fields = OrderedDict (sorted (list (fields .items ())))
527+
525528 assert isinstance (fields , collections .Mapping ) and len (fields ) > 0 , (
526529 '{} fields must be a mapping (dict / OrderedDict) with field names as keys or a '
527530 'function which returns such a mapping.'
You can’t perform that action at this time.
0 commit comments