5
5
from ..core .fields import Field
6
6
from ..core .types .definitions import NonNull
7
7
from ..core .types .scalars import ID , Int , String
8
- from ..utils import with_context
8
+ from ..utils . wrap_resolver_function import has_context , with_context
9
9
10
10
11
11
class ConnectionField (Field ):
@@ -25,17 +25,24 @@ def __init__(self, type, resolver=None, description='',
25
25
** kwargs )
26
26
self .connection_type = connection_type
27
27
self .edge_type = edge_type
28
-
29
- def resolver (self , instance , args , info ):
28
+
29
+ @with_context
30
+ def resolver (self , instance , args , context , info ):
30
31
schema = info .schema .graphene_schema
31
32
connection_type = self .get_type (schema )
32
- resolved = super (ConnectionField , self ).resolver (instance , args , info )
33
+
34
+ resolver = super (ConnectionField , self ).resolver
35
+ if has_context (resolver ):
36
+ resolved = super (ConnectionField , self ).resolver (instance , args , context , info )
37
+ else :
38
+ resolved = super (ConnectionField , self ).resolver (instance , args , info )
39
+
33
40
if isinstance (resolved , connection_type ):
34
41
return resolved
35
- return self .from_list (connection_type , resolved , args , info )
42
+ return self .from_list (connection_type , resolved , args , context , info )
36
43
37
44
def from_list (self , connection_type , resolved , args , info ):
38
- return connection_type .from_list (resolved , args , info )
45
+ return connection_type .from_list (resolved , args , context , info )
39
46
40
47
def get_connection_type (self , node ):
41
48
connection_type = self .connection_type or node .get_connection_type ()
0 commit comments