@@ -149,10 +149,13 @@ def filter_args(self):
149
149
if self ._type ._meta .filter_fields :
150
150
for field , filter_collection in self ._type ._meta .filter_fields .items ():
151
151
for each in filter_collection :
152
- filter_type = getattr (
153
- graphene ,
154
- str (self ._type ._meta .fields [field ].type ).replace ("!" , "" ),
155
- )
152
+ if each == 'max_distance' and str (self ._type ._meta .fields [field ].type ) == 'PointFieldType' :
153
+ filter_type = graphene .Int
154
+ else :
155
+ filter_type = getattr (
156
+ graphene ,
157
+ str (self ._type ._meta .fields [field ].type ).replace ("!" , "" ),
158
+ )
156
159
157
160
# handle special cases
158
161
advanced_filter_types = {
@@ -175,10 +178,8 @@ def get_reference_field(r, kv):
175
178
mongo_field = getattr (self .model , kv [0 ], None )
176
179
if isinstance (
177
180
mongo_field ,
178
- (mongoengine .LazyReferenceField , mongoengine .ReferenceField ),
181
+ (mongoengine .LazyReferenceField , mongoengine .ReferenceField , mongoengine . GenericReferenceField ),
179
182
):
180
- field = convert_mongoengine_field (mongo_field , self .registry )
181
- if isinstance (mongo_field , mongoengine .GenericReferenceField ):
182
183
r .update ({kv [0 ]: graphene .ID ()})
183
184
return r
184
185
if callable (getattr (field , "get_type" , None )):
@@ -216,6 +217,10 @@ def get_queryset(self, model, info, required_fields=list(), skip=None, limit=Non
216
217
reference_obj = get_document (self .registry ._registry_string_map [from_global_id (arg )[0 ]])(
217
218
pk = from_global_id (arg )[1 ])
218
219
hydrated_references [arg_name ] = reference_obj
220
+ elif '__near' in arg_name and isinstance (getattr (self .model , arg_name .split ('__' )[0 ]),
221
+ mongoengine .fields .PointField ):
222
+ location = args .pop (arg_name , None )
223
+ hydrated_references [arg_name ] = location ["coordinates" ]
219
224
elif arg_name == "id" :
220
225
hydrated_references ["id" ] = from_global_id (args .pop ("id" , None ))[1 ]
221
226
args .update (hydrated_references )
0 commit comments