Geo Location filter is not working
thefazeelahmed opened this issue · 0 comments
thefazeelahmed commented
For Me This Query Always return empty results
I've created my own resolver with same geoDistance filter and that works fine but this code doesn't work for me.
"findMany",
CheckinTC.getResolver("findMany").addFilterArg({
name: "geoDistance",
type: `input GeoDistance {
lng: Float!
lat: Float!
# Distance in meters
distance: Float!
}`,
description: "Search by distance in meters",
query: (rawQuery, value) => {
if (!value.lng || !value.lat || !value.distance) return;
rawQuery["location"] = {
$near: {
$geometry: {
type: "Point",
coordinates: [value.lng, value.lat],
},
$maxDistance: value.distance, // <distance in meters>
},
};
},
})
);
This Works Fine For Me But I need Additional filters so it will be good if i can use default ("Find Many Resolver") with one of my custom filter
name: "findwithinradius",
args: { lat: "Float!", lng: "Float!", distance: "Float!" },
type: [CheckinTC],
resolve: async ({ source, args }) => {
console.log(args.lng);
const data = await Checkin.find({
location: {
$near: {
$geometry: {
type: "Point",
coordinates: [args.lng, args.lat],
},
$maxDistance: args.distance,
},
},
});
return data;
},
});