Skip to content

Commit 74e6094

Browse files
Arun S KumarArun S Kumar
authored andcommitted
Queryset added to info.context
1 parent 6981bfe commit 74e6094

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

graphene_mongo/fields.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
from bson import DBRef
99
from graphene import Context
1010
from graphene.utils.str_converters import to_snake_case
11+
from graphql import ResolveInfo
1112
from promise import Promise
1213
from graphql_relay import from_global_id
1314
from graphene.relay import ConnectionField
@@ -232,6 +233,10 @@ def default_resolver(self, _root, info, only_fields=list(), **args):
232233

233234
if callable(getattr(self.model, "objects", None)):
234235
iterables = self.get_queryset(self.model, info, only_fields, **args)
236+
if isinstance(info, ResolveInfo):
237+
if not info.context:
238+
info.context = Context()
239+
info.context.queryset = iterables
235240
list_length = iterables.count()
236241
else:
237242
iterables = []
@@ -265,9 +270,10 @@ def chained_resolver(self, resolver, is_partial, root, info, **args):
265270
for arg_name, arg in args.copy().items():
266271
if arg_name not in self.model._fields_ordered:
267272
args_copy.pop(arg_name)
268-
if not info.context:
269-
info.context = Context()
270-
info.context.queryset = self.get_queryset(self.model, info, only_fields, **args_copy)
273+
if isinstance(info, ResolveInfo):
274+
if not info.context:
275+
info.context = Context()
276+
info.context.queryset = self.get_queryset(self.model, info, only_fields, **args_copy)
271277
# XXX: Filter nested args
272278
resolved = resolver(root, info, **args)
273279
if resolved is not None:

0 commit comments

Comments
 (0)