mirror of
https://github.com/brendan-ch/project-inter-server.git
synced 2026-04-19 08:50:29 +00:00
add orderedStop property for Route
This commit is contained in:
@@ -17,7 +17,7 @@ type System {
|
|||||||
type Route {
|
type Route {
|
||||||
name: String!
|
name: String!
|
||||||
id: ID!
|
id: ID!
|
||||||
orderedStops: [OrderedStop!]
|
orderedStop(forStopId: ID): OrderedStop
|
||||||
shuttles: [Shuttle!]
|
shuttles: [Shuttle!]
|
||||||
polylineCoordinates: [Coordinates!]!
|
polylineCoordinates: [Coordinates!]!
|
||||||
color: String!
|
color: String!
|
||||||
|
|||||||
@@ -110,8 +110,25 @@ export const resolvers: Resolvers<ServerContext> = {
|
|||||||
route: parent,
|
route: parent,
|
||||||
id,
|
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: {
|
Shuttle: {
|
||||||
eta: async (parent, args, contextValue, info) => {
|
eta: async (parent, args, contextValue, info) => {
|
||||||
if (!args.forStopId) return null;
|
if (!args.forStopId) return null;
|
||||||
|
|||||||
Reference in New Issue
Block a user