import { schemaComposer } from './schemaComposer' ; import { UserTC } from './models/user' ; schemaComposer . Query . addFields ( { userById : UserTC . mongooseResolvers . findById ( ) , userByIds : UserTC . mongooseResolvers . findByIds ( ) , userOne : UserTC . mongooseResolvers . findOne ( ) , userMany : UserTC . mongooseResolvers . 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 [ 'address.geo' ] = { $near : { $geometry : { type : 'Point' , coordinates : [ value . lng , value . lat ] , } , $maxDistance : value . distance , } , } ; } , } ) , userTotal : UserTC . mongooseResolvers . count ( ) , userConnection : UserTC . mongooseResolvers . connection ( ) , userPagination : UserTC . mongooseResolvers . pagination ( ) , } ) ; schemaComposer . Mutation . addFields ( { userCreate : UserTC . mongooseResolvers . createOne ( ) , userCreateMany : UserTC . mongooseResolvers . createMany ( ) , userUpdateById : UserTC . mongooseResolvers . updateById ( ) , userUpdateOne : UserTC . mongooseResolvers . updateOne ( ) , userUpdateMany : UserTC . mongooseResolvers . updateMany ( ) , userRemoveById : UserTC . mongooseResolvers . removeById ( ) , userRemoveOne : UserTC . mongooseResolvers . removeOne ( ) , userRemoveMany : UserTC . mongooseResolvers . removeMany ( ) , } ) ; const graphqlSchema = schemaComposer . buildSchema ( ) ; export default graphqlSchema ;