diff --git a/src/resolvers/EtaResolvers.ts b/src/resolvers/EtaResolvers.ts index b5e7c65..0dabe62 100644 --- a/src/resolvers/EtaResolvers.ts +++ b/src/resolvers/EtaResolvers.ts @@ -4,10 +4,18 @@ import { ServerContext } from "../ServerContext"; export const EtaResolvers: Resolvers = { ETA: { stop: async (parent, args, contextValue, info) => { - return await contextValue.shuttleRepository.getStopById(parent.stopId); + if (!parent.shuttle) return null; + const system = contextValue.findSystemById(parent.shuttle.systemId); + if (!system) return null; + + return await system.shuttleRepository.getStopById(parent.stopId); }, shuttle: async (parent, args, contextValue, info) => { - return await contextValue.shuttleRepository.getShuttleById(parent.shuttleId); + if (!parent.stop) return null; + const system = contextValue.findSystemById(parent.stop.systemId); + if (!system) return null; + + return await system.shuttleRepository.getShuttleById(parent.shuttleId); }, }, }