mirror of
https://github.com/brendan-ch/project-inter-server.git
synced 2026-04-16 23:40:32 +00:00
add orderedStop property for Route
This commit is contained in:
@@ -17,7 +17,7 @@ type System {
|
||||
type Route {
|
||||
name: String!
|
||||
id: ID!
|
||||
orderedStops: [OrderedStop!]
|
||||
orderedStop(forStopId: ID): OrderedStop
|
||||
shuttles: [Shuttle!]
|
||||
polylineCoordinates: [Coordinates!]!
|
||||
color: String!
|
||||
|
||||
@@ -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) => {
|
||||
|
||||
Reference in New Issue
Block a user