From bbf36fe1b7d90df3c601f5da0ae9eb818c615097 Mon Sep 17 00:00:00 2001 From: Roshan R Chandar Date: Tue, 21 Nov 2023 18:30:13 +0530 Subject: [PATCH] fix(connection_field): respects non_filter_fields when argument name is same as field name --- graphene_mongo/fields.py | 6 +++++- graphene_mongo/fields_async.py | 6 +++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/graphene_mongo/fields.py b/graphene_mongo/fields.py index 3cef0f44..ef819855 100644 --- a/graphene_mongo/fields.py +++ b/graphene_mongo/fields.py @@ -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) diff --git a/graphene_mongo/fields_async.py b/graphene_mongo/fields_async.py index 8886823d..285dac41 100644 --- a/graphene_mongo/fields_async.py +++ b/graphene_mongo/fields_async.py @@ -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)