diff --git a/src/resolvers/QueryResolvers.ts b/src/resolvers/QueryResolvers.ts index 1b316c8..34c31e3 100644 --- a/src/resolvers/QueryResolvers.ts +++ b/src/resolvers/QueryResolvers.ts @@ -4,25 +4,49 @@ import { Resolvers } from "../generated/graphql"; export const QueryResolvers: Resolvers = { Query: { systems: async (_parent, args, contextValue, _info) => { - return await contextValue.shuttleRepository.getSystemIfExists(); + return contextValue.systems.map((system) => { + return { + name: system.name, + id: system.id, + }; + }) }, system: async (_parent, args, contextValue, _info) => { if (!args.id) return null; - const system = await contextValue.shuttleRepository.getSystemById(args.id); - if (system === null) return null; + const system = contextValue.systems.find((system) => { + return system.id === args.id; + }); + if (system === undefined) return null; return { name: system.name, id: system.id, }; }, + // TODO: Update the GraphQL schema to require a system ID isNotificationScheduled: async (_parent, args, contextValue, _info) => { const notificationData = args.input; - return await contextValue.notificationRepository.isNotificationScheduled(notificationData); + + for (let system of contextValue.systems) { + const isScheduled = await system.notificationRepository.isNotificationScheduled(notificationData); + if (isScheduled) { + return true; + } + } + + return false; }, secondsThresholdForNotification: async (_parent, args, contextValue, _info) => { const notificationData = args.input; - return await contextValue.notificationRepository.getSecondsThresholdForNotificationIfExists(notificationData); + + for (let system of contextValue.systems) { + const isScheduled = await system.notificationRepository.isNotificationScheduled(notificationData); + if (isScheduled) { + return await system.notificationRepository.getSecondsThresholdForNotificationIfExists(args.input); + } + } + + return null; }, }, }