1+ from collections import OrderedDict
2+
13from graphql .type import (
24 GraphQLArgument ,
35 GraphQLBoolean ,
1113from ..utils import resolve_maybe_thunk
1214
1315
14- connection_args = {
15- 'before' : GraphQLArgument (GraphQLString ),
16- 'after' : GraphQLArgument (GraphQLString ),
17- 'first' : GraphQLArgument (GraphQLInt ),
18- 'last' : GraphQLArgument (GraphQLInt ),
19- }
16+ connection_args = OrderedDict ((
17+ ( 'before' , GraphQLArgument (GraphQLString ) ),
18+ ( 'after' , GraphQLArgument (GraphQLString ) ),
19+ ( 'first' , GraphQLArgument (GraphQLInt ) ),
20+ ( 'last' , GraphQLArgument (GraphQLInt ) ),
21+ ))
2022
2123
2224def connection_definitions (name , node_type , resolve_node = None , resolve_cursor = None , edge_fields = None , connection_fields = None ):
23- edge_fields = edge_fields or {}
24- connection_fields = connection_fields or {}
25+ edge_fields = edge_fields or OrderedDict ()
26+ connection_fields = connection_fields or OrderedDict ()
2527 edge_type = GraphQLObjectType (
2628 name + 'Edge' ,
2729 description = 'An edge in a connection.' ,
28- fields = lambda : dict ({
29- 'node' : GraphQLField (
30+ fields = lambda : OrderedDict ((
31+ ( 'node' , GraphQLField (
3032 node_type ,
3133 resolver = resolve_node ,
3234 description = 'The item at the end of the edge' ,
33- ),
34- 'cursor' : GraphQLField (
35+ )) ,
36+ ( 'cursor' , GraphQLField (
3537 GraphQLNonNull (GraphQLString ),
3638 resolver = resolve_cursor ,
3739 description = 'A cursor for use in pagination' ,
38- )
39- } , ** resolve_maybe_thunk (edge_fields ))
40+ )),
41+ ) , ** resolve_maybe_thunk (edge_fields ))
4042 )
4143
4244 connection_type = GraphQLObjectType (
4345 name + 'Connection' ,
4446 description = 'A connection to a list of items.' ,
45- fields = lambda : dict ({
46- 'pageInfo' : GraphQLField (
47+ fields = lambda : OrderedDict ((
48+ ( 'pageInfo' , GraphQLField (
4749 GraphQLNonNull (page_info_type ),
4850 description = 'The Information to aid in pagination' ,
49- ),
50- 'edges' : GraphQLField (
51+ )) ,
52+ ( 'edges' , GraphQLField (
5153 GraphQLList (edge_type ),
5254 description = 'A list of edges.' ,
53- )
54- } , ** resolve_maybe_thunk (connection_fields ))
55+ )),
56+ ) , ** resolve_maybe_thunk (connection_fields ))
5557 )
5658
5759 return edge_type , connection_type
@@ -61,22 +63,22 @@ def connection_definitions(name, node_type, resolve_node=None, resolve_cursor=No
6163page_info_type = GraphQLObjectType (
6264 'PageInfo' ,
6365 description = 'Information about pagination in a connection.' ,
64- fields = lambda : {
65- 'hasNextPage' : GraphQLField (
66+ fields = lambda : OrderedDict ((
67+ ( 'hasNextPage' , GraphQLField (
6668 GraphQLNonNull (GraphQLBoolean ),
6769 description = 'When paginating forwards, are there more items?' ,
68- ),
69- 'hasPreviousPage' : GraphQLField (
70+ )) ,
71+ ( 'hasPreviousPage' , GraphQLField (
7072 GraphQLNonNull (GraphQLBoolean ),
7173 description = 'When paginating backwards, are there more items?' ,
72- ),
73- 'startCursor' : GraphQLField (
74+ )) ,
75+ ( 'startCursor' , GraphQLField (
7476 GraphQLString ,
7577 description = 'When paginating backwards, the cursor to continue.' ,
76- ),
77- 'endCursor' : GraphQLField (
78+ )) ,
79+ ( 'endCursor' , GraphQLField (
7880 GraphQLString ,
7981 description = 'When paginating forwards, the cursor to continue.' ,
80- ),
81- }
82+ )) ,
83+ ))
8284)
0 commit comments