Skip to content

Commit 57044f7

Browse files
committed
Fixed variable tests errors
1 parent 3fa0d0a commit 57044f7

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed

graphql/execution/tests/test_variables.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import json
2+
from collections import OrderedDict
23

34
from pytest import raises
45

@@ -17,12 +18,12 @@
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

2728
stringify = lambda obj: json.dumps(obj, sort_keys=True)
2829

graphql/type/definition.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff 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.'

0 commit comments

Comments
 (0)