diff --git a/src/resolvers/MutationResolvers.ts b/src/resolvers/MutationResolvers.ts index 9332e8b..18cb3d2 100644 --- a/src/resolvers/MutationResolvers.ts +++ b/src/resolvers/MutationResolvers.ts @@ -4,9 +4,27 @@ import { ServerContext } from "../ServerContext"; export const MutationResolvers: Resolvers = { Mutation: { scheduleNotification: async (_parent, args, context, _info) => { + const shuttle = await context.repository.getShuttleById(args.input.shuttleId); + if (!shuttle) { + return { + message: "Shuttle ID doesn't exist", + success: false, + } + } + const stop = await context.repository.getStopById(args.input.stopId); + if (!stop) { + return { + message: "Stop ID doesn't exist", + success: false, + } + } + + await context.notificationService.scheduleNotification(args.input); + const response: NotificationResponse = { - message: "Not implemented", - success: false + message: "Notification scheduled", + success: true, + data: args.input, } return response; },