Skip to content

Commit

Permalink
Merge pull request #9 from Roshan-R/fix_non_filter_field
Browse files Browse the repository at this point in the history
fix(connection_field): respects non_filter_fields when argument name …
  • Loading branch information
abhinand-c authored Nov 21, 2023
2 parents cb56602 + bbf36fe commit 5b0f9b9
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
6 changes: 5 additions & 1 deletion graphene_mongo/fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -518,7 +518,11 @@ def chained_resolver(self, resolver, is_partial, root, info, **args):
from itertools import filterfalse
connection_fields = [field for field in self.fields if
type(self.fields[field]) == MongoengineConnectionField]
filterable_args = tuple(filterfalse(connection_fields.__contains__, list(self.model._fields_ordered)))
filter_connection = lambda x: (
connection_fields.__contains__(x)
or self._type._meta.non_filter_fields.__contains__(x)
)
filterable_args = tuple(filterfalse(filter_connection, list(self.model._fields_ordered)))
for arg_name, arg in args.copy().items():
if arg_name not in filterable_args + tuple(self.filter_args.keys()):
args_copy.pop(arg_name)
Expand Down
6 changes: 5 additions & 1 deletion graphene_mongo/fields_async.py
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,11 @@ async def chained_resolver(self, resolver, is_partial, root, info, **args):
from itertools import filterfalse
connection_fields = [field for field in self.fields if
type(self.fields[field]) == AsyncMongoengineConnectionField]
filterable_args = tuple(filterfalse(connection_fields.__contains__, list(self.model._fields_ordered)))
filter_connection = lambda x: (
connection_fields.__contains__(x)
or self._type._meta.non_filter_fields.__contains__(x)
)
filterable_args = tuple(filterfalse(filter_connection, list(self.model._fields_ordered)))
for arg_name, arg in args.copy().items():
if arg_name not in filterable_args + tuple(self.filter_args.keys()):
args_copy.pop(arg_name)
Expand Down

0 comments on commit 5b0f9b9

Please sign in to comment.