mirror of
https://github.com/brendan-ch/project-inter-server.git
synced 2026-04-17 07:50:31 +00:00
implement shuttle/route resolvers
This commit is contained in:
@@ -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: {
|
||||||
|
|||||||
Reference in New Issue
Block a user