implement shuttle/route resolvers

This commit is contained in:
2024-12-26 18:05:07 -08:00
parent 014a2ce50f
commit 442179b805

View File

@@ -85,6 +85,15 @@ export const resolvers: Resolvers<ServerContext> = {
id: shuttle.id, id: shuttle.id,
name: shuttle.name, name: shuttle.name,
}; };
},
shuttles: async (parent, args, contextValue, info) => {
const shuttles = await contextValue.repository.getShuttlesBySystemId(parent.id);
return shuttles.map(shuttle => ({
coordinates: shuttle.coordinates,
name: shuttle.name,
id: shuttle.id,
}));
} }
}, },
Route: { Route: {
@@ -149,6 +158,20 @@ export const resolvers: Resolvers<ServerContext> = {
} }
return []; return [];
},
route: async (parent, args, contextValue, info) => {
const shuttle = await contextValue.repository.getShuttleById(parent.id);
if (shuttle === null) return null;
const route = await contextValue.repository.getRouteById(shuttle?.routeId);
if (route === null) return null;
return {
color: route.color,
id: route.id,
name: route.name,
polylineCoordinates: route.polylineCoordinates,
}
} }
}, },
Stop: { Stop: {