Skip to content

Commit c4f29f0

Browse files
committed
Added context to connectionfield resolver
1 parent b431bfe commit c4f29f0

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

graphene/relay/fields.py

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
from ..core.fields import Field
66
from ..core.types.definitions import NonNull
77
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
99

1010

1111
class ConnectionField(Field):
@@ -25,17 +25,24 @@ def __init__(self, type, resolver=None, description='',
2525
**kwargs)
2626
self.connection_type = connection_type
2727
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):
3031
schema = info.schema.graphene_schema
3132
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+
3340
if isinstance(resolved, connection_type):
3441
return resolved
35-
return self.from_list(connection_type, resolved, args, info)
42+
return self.from_list(connection_type, resolved, args, context, info)
3643

3744
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)
3946

4047
def get_connection_type(self, node):
4148
connection_type = self.connection_type or node.get_connection_type()

0 commit comments

Comments
 (0)