mirror of
https://github.com/brendan-ch/project-inter-server.git
synced 2026-04-17 16:00:32 +00:00
40 lines
1.1 KiB
TypeScript
40 lines
1.1 KiB
TypeScript
import { NotificationInput, NotificationResponse, Resolvers } from "../generated/graphql";
|
|
import { ServerContext } from "../ServerContext";
|
|
|
|
export const MutationResolvers: Resolvers<ServerContext> = {
|
|
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: "Notification scheduled",
|
|
success: true,
|
|
data: args.input,
|
|
}
|
|
return response;
|
|
},
|
|
cancelNotification: async (_parent, args, context, _info) => {
|
|
const response: NotificationResponse = {
|
|
message: "Not implemented",
|
|
success: false
|
|
}
|
|
return response;
|
|
},
|
|
},
|
|
}
|