Skip to content

Commit 3ef74bc

Browse files
authored
Merge pull request #169 from arunsureshkumar/master
Support added for Graphene Federation
2 parents 97266e6 + e44c660 commit 3ef74bc

File tree

1 file changed

+14
-8
lines changed

1 file changed

+14
-8
lines changed

graphene_mongo/fields.py

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -44,12 +44,12 @@ def __init__(self, type, *args, **kwargs):
4444

4545
@property
4646
def type(self):
47-
from .types import GrapheneMongoengineObjectTypes
47+
from .types import MongoengineObjectType
4848

4949
_type = super(ConnectionField, self).type
5050
assert issubclass(
51-
_type, GrapheneMongoengineObjectTypes
52-
), "MongoengineConnectionField only accepts Mongoengine object types"
51+
_type, MongoengineObjectType
52+
), "MongoengineConnectionField only accepts MongoengineObjectType types"
5353
assert _type._meta.connection, "The type {} doesn't have a connection".format(
5454
_type.__name__
5555
)
@@ -79,7 +79,7 @@ def registry(self):
7979
def args(self):
8080
return to_arguments(
8181
self._base_args or OrderedDict(),
82-
dict(dict(self.field_args, **self.advance_args), **self.filter_args),
82+
dict(dict(dict(self.field_args, **self.advance_args), **self.filter_args), **self.extended_args),
8383
)
8484

8585
@args.setter
@@ -96,7 +96,8 @@ def is_filterable(k):
9696
Returns:
9797
bool
9898
"""
99-
99+
if hasattr(self.fields[k].type, '_sdl'):
100+
return False
100101
if not hasattr(self.model, k):
101102
return False
102103
if isinstance(getattr(self.model, k), property):
@@ -201,6 +202,14 @@ def get_advance_field(r, kv):
201202

202203
return reduce(get_advance_field, self.fields.items(), {})
203204

205+
@property
206+
def extended_args(self):
207+
args = OrderedDict()
208+
for k, each in self.fields.items():
209+
if hasattr(each.type, '_sdl'):
210+
args.update({k: graphene.ID()})
211+
return args
212+
204213
@property
205214
def fields(self):
206215
self._type = get_type(self._type)
@@ -394,9 +403,6 @@ def chained_resolver(self, resolver, is_partial, root, info, **args):
394403
self.filter_args.keys()):
395404
args_copy.pop(arg_name)
396405
if arg_name == '_id' and isinstance(arg, dict):
397-
args_copy['pk__in'] = arg['$in']
398-
elif "$ne" in arg:
399-
args_copy['pk__ne'] = arg['$ne']
400406
operation = list(arg.keys())[0]
401407
args_copy['pk' + operation.replace('$', '__')] = arg[operation]
402408
if '.' in arg_name:

0 commit comments

Comments
 (0)