add orderedStop property for Route

This commit is contained in:
2024-12-26 18:22:34 -08:00
parent 442179b805
commit 4b16790525
2 changed files with 19 additions and 2 deletions

View File

@@ -110,7 +110,24 @@ export const resolvers: Resolvers<ServerContext> = {
route: parent,
id,
}));
}
},
orderedStop: async (parent, args, contextValue, info) => {
if (!args.forStopId) return null;
const orderedStop = await contextValue.repository.getOrderedStopByRouteAndStopId(parent.id, args.forStopId);
if (!orderedStop) return null;
const stop = await contextValue.repository.getStopById(orderedStop.stopId);
if (!stop) return null;
return {
stop: {
id: stop.id,
name: stop.name,
coordinates: stop.coordinates as Coordinates,
},
route: parent,
}
},
},
Shuttle: {
eta: async (parent, args, contextValue, info) => {