mirror of
https://github.com/brendan-ch/project-inter-server.git
synced 2026-04-17 16:00:32 +00:00
update shuttle resolvers
This commit is contained in:
@@ -5,7 +5,11 @@ export const ShuttleResolvers: Resolvers<ServerContext> = {
|
|||||||
Shuttle: {
|
Shuttle: {
|
||||||
eta: async (parent, args, contextValue, info) => {
|
eta: async (parent, args, contextValue, info) => {
|
||||||
if (!args.forStopId) return null;
|
if (!args.forStopId) return null;
|
||||||
const etaForStopId = await contextValue.shuttleRepository.getEtaForShuttleAndStopId(parent.id, args.forStopId);
|
|
||||||
|
const system = contextValue.findSystemById(parent.systemId);
|
||||||
|
if (!system) return null;
|
||||||
|
|
||||||
|
const etaForStopId = await system.shuttleRepository.getEtaForShuttleAndStopId(parent.id, args.forStopId);
|
||||||
if (etaForStopId === null) return null;
|
if (etaForStopId === null) return null;
|
||||||
|
|
||||||
return {
|
return {
|
||||||
@@ -16,7 +20,10 @@ export const ShuttleResolvers: Resolvers<ServerContext> = {
|
|||||||
};
|
};
|
||||||
},
|
},
|
||||||
etas: async (parent, args, contextValue, info) => {
|
etas: async (parent, args, contextValue, info) => {
|
||||||
const etasForShuttle = await contextValue.shuttleRepository.getEtasForShuttleId(parent.id);
|
const system = contextValue.findSystemById(parent.systemId);
|
||||||
|
if (!system) return null;
|
||||||
|
|
||||||
|
const etasForShuttle = await system.shuttleRepository.getEtasForShuttleId(parent.id);
|
||||||
if (!etasForShuttle) return null;
|
if (!etasForShuttle) return null;
|
||||||
|
|
||||||
const computedEtas = await Promise.all(etasForShuttle.map(async ({
|
const computedEtas = await Promise.all(etasForShuttle.map(async ({
|
||||||
@@ -38,7 +45,10 @@ export const ShuttleResolvers: Resolvers<ServerContext> = {
|
|||||||
return [];
|
return [];
|
||||||
},
|
},
|
||||||
route: async (parent, args, contextValue, info) => {
|
route: async (parent, args, contextValue, info) => {
|
||||||
const route = await contextValue.shuttleRepository.getRouteById(parent.routeId);
|
const system = contextValue.findSystemById(parent.systemId);
|
||||||
|
if (!system) return null;
|
||||||
|
|
||||||
|
const route = await system.shuttleRepository.getRouteById(parent.routeId);
|
||||||
if (route === null) return null;
|
if (route === null) return null;
|
||||||
|
|
||||||
return {
|
return {
|
||||||
@@ -46,6 +56,7 @@ export const ShuttleResolvers: Resolvers<ServerContext> = {
|
|||||||
id: route.id,
|
id: route.id,
|
||||||
name: route.name,
|
name: route.name,
|
||||||
polylineCoordinates: route.polylineCoordinates,
|
polylineCoordinates: route.polylineCoordinates,
|
||||||
|
systemId: parent.systemId,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user