mirror of
https://github.com/brendan-ch/project-inter-server.git
synced 2026-04-17 07:50:31 +00:00
update route resolvers
This commit is contained in:
@@ -4,7 +4,10 @@ import { ServerContext } from "../ServerContext";
|
||||
export const RouteResolvers: Resolvers<ServerContext> = {
|
||||
Route: {
|
||||
shuttles: async (parent, args, contextValue, info) => {
|
||||
const shuttles = await contextValue.shuttleRepository.getShuttlesByRouteId(parent.id);
|
||||
const system = contextValue.findSystemById(parent.systemId);
|
||||
if (!system) return null;
|
||||
|
||||
const shuttles = await system.shuttleRepository.getShuttlesByRouteId(parent.id);
|
||||
|
||||
return shuttles.map(({
|
||||
coordinates,
|
||||
@@ -17,15 +20,20 @@ export const RouteResolvers: Resolvers<ServerContext> = {
|
||||
route: parent,
|
||||
routeId: parent.id,
|
||||
id,
|
||||
orientationInDegrees
|
||||
orientationInDegrees,
|
||||
systemId: parent.systemId,
|
||||
}));
|
||||
},
|
||||
orderedStop: async (parent, args, contextValue, info) => {
|
||||
if (!args.forStopId) return null;
|
||||
const orderedStop = await contextValue.shuttleRepository.getOrderedStopByRouteAndStopId(parent.id, args.forStopId);
|
||||
|
||||
const system = contextValue.findSystemById(parent.systemId);
|
||||
if (!system) return null;
|
||||
|
||||
const orderedStop = await system.shuttleRepository.getOrderedStopByRouteAndStopId(parent.id, args.forStopId);
|
||||
if (!orderedStop) return null;
|
||||
|
||||
const stop = await contextValue.shuttleRepository.getStopById(orderedStop.stopId);
|
||||
const stop = await system.shuttleRepository.getStopById(orderedStop.stopId);
|
||||
if (!stop) return null;
|
||||
|
||||
return {
|
||||
|
||||
Reference in New Issue
Block a user