@@ -28,7 +28,6 @@ def test_batches_correctly(executor):
28
28
29
29
schema = GraphQLSchema (query = Query )
30
30
31
-
32
31
doc = '''
33
32
{
34
33
business1: getBusiness(id: "1") {
@@ -41,9 +40,8 @@ def test_batches_correctly(executor):
41
40
'''
42
41
doc_ast = parse (doc )
43
42
44
-
45
43
load_calls = []
46
-
44
+
47
45
class BusinessDataLoader (DataLoader ):
48
46
def batch_load_fn (self , keys ):
49
47
load_calls .append (keys )
@@ -52,7 +50,6 @@ def batch_load_fn(self, keys):
52
50
class Context (object ):
53
51
business_data_loader = BusinessDataLoader ()
54
52
55
-
56
53
result = execute (schema , doc_ast , None , context_value = Context (), executor = executor )
57
54
assert not result .errors
58
55
assert result .data == {
@@ -63,7 +60,7 @@ class Context(object):
63
60
'id' : '2'
64
61
},
65
62
}
66
- assert load_calls == [['1' ,'2' ]]
63
+ assert load_calls == [['1' , '2' ]]
67
64
68
65
69
66
@pytest .mark .parametrize ("executor" , [
@@ -78,8 +75,11 @@ def test_batches_multiple_together(executor):
78
75
79
76
Business = GraphQLObjectType ('Business' , lambda : {
80
77
'id' : GraphQLField (GraphQLID , resolver = lambda root , info , ** args : root ),
81
- 'location' : GraphQLField (Location ,
82
- resolver = lambda root , info , ** args : info .context .location_data_loader .load ('location-{}' .format (root ))
78
+ 'location' : GraphQLField (
79
+ Location ,
80
+ resolver = lambda root , info , ** args : info .context .location_data_loader .load (
81
+ 'location-{}' .format (root )
82
+ )
83
83
),
84
84
})
85
85
@@ -94,7 +94,6 @@ def test_batches_multiple_together(executor):
94
94
95
95
schema = GraphQLSchema (query = Query )
96
96
97
-
98
97
doc = '''
99
98
{
100
99
business1: getBusiness(id: "1") {
@@ -113,16 +112,15 @@ def test_batches_multiple_together(executor):
113
112
'''
114
113
doc_ast = parse (doc )
115
114
116
-
117
115
business_load_calls = []
118
-
116
+
119
117
class BusinessDataLoader (DataLoader ):
120
118
def batch_load_fn (self , keys ):
121
119
business_load_calls .append (keys )
122
120
return Promise .resolve (keys )
123
121
124
122
location_load_calls = []
125
-
123
+
126
124
class LocationDataLoader (DataLoader ):
127
125
def batch_load_fn (self , keys ):
128
126
location_load_calls .append (keys )
@@ -132,7 +130,6 @@ class Context(object):
132
130
business_data_loader = BusinessDataLoader ()
133
131
location_data_loader = LocationDataLoader ()
134
132
135
-
136
133
result = execute (schema , doc_ast , None , context_value = Context (), executor = executor )
137
134
assert not result .errors
138
135
assert result .data == {
@@ -149,5 +146,5 @@ class Context(object):
149
146
}
150
147
},
151
148
}
152
- assert business_load_calls == [['1' ,'2' ]]
153
- assert location_load_calls == [['location-1' ,'location-2' ]]
149
+ assert business_load_calls == [['1' , '2' ]]
150
+ assert location_load_calls == [['location-1' , 'location-2' ]]
0 commit comments