import User from "../../../entities/User" ; import { ReportMovementMutationArgs , ReportMovementResponse } from "../../../types/graph" ; import { Resolvers } from "../../../types/resolvers" ; import cleanNullArgs from "../../../utils/cleanNullArg" ; import privateResolver from "../../../utils/privateResolver" ; const resolvers = { Mutation : { ReportMovement : privateResolver ( async ( _ , args , { req , pubSub } ) : Promise < ReportMovementResponse > => { const user = req . user ; const notNull = cleanNullArgs ( args ) ; try { await User . update ( { id : user . id } , { ... notNull } ) ; const updatedUser = await User . findOne ( { id : user . id } ) ; pubSub . publish ( "driverUpdate" , { DriversSubscription : updatedUser } ) ; return { ok : true , error : null } ; } catch ( error ) { return { ok : false , error : error . message } ; } } ) } } ; export default resolvers ;