|
8 | 8 | from bson import DBRef
|
9 | 9 | from graphene import Context
|
10 | 10 | from graphene.utils.str_converters import to_snake_case
|
| 11 | +from graphql import ResolveInfo |
11 | 12 | from promise import Promise
|
12 | 13 | from graphql_relay import from_global_id
|
13 | 14 | from graphene.relay import ConnectionField
|
@@ -232,6 +233,10 @@ def default_resolver(self, _root, info, only_fields=list(), **args):
|
232 | 233 |
|
233 | 234 | if callable(getattr(self.model, "objects", None)):
|
234 | 235 | 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 |
235 | 240 | list_length = iterables.count()
|
236 | 241 | else:
|
237 | 242 | iterables = []
|
@@ -265,9 +270,10 @@ def chained_resolver(self, resolver, is_partial, root, info, **args):
|
265 | 270 | for arg_name, arg in args.copy().items():
|
266 | 271 | if arg_name not in self.model._fields_ordered:
|
267 | 272 | 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) |
271 | 277 | # XXX: Filter nested args
|
272 | 278 | resolved = resolver(root, info, **args)
|
273 | 279 | if resolved is not None:
|
|
0 commit comments