add shuttles resolver on route

This commit is contained in:
2024-12-22 19:56:57 -08:00
parent 0221bda314
commit f615db544d

View File

@@ -88,6 +88,20 @@ export const resolvers: Resolvers<ServerContext> = {
} }
}, },
Route: { Route: {
shuttles: async (parent, args, contextValue, info) => {
const shuttles = await contextValue.repository.getShuttlesByRouteId(parent.id);
return shuttles.map(({
coordinates,
name,
id,
}) => ({
coordinates: coordinates as Coordinates,
name,
route: parent,
id,
}));
}
}, },
Shuttle: { Shuttle: {
eta: (parent, args, contextValue, info) => { eta: (parent, args, contextValue, info) => {