mirror of
https://github.com/brendan-ch/project-inter-server.git
synced 2026-04-17 07:50:31 +00:00
add resolver for previous stop
This commit is contained in:
@@ -155,6 +155,28 @@ export const resolvers: Resolvers<ServerContext> = {
|
|||||||
const nextStopObject = await contextValue.repository.getStopById(nextOrderedStop.stopId);
|
const nextStopObject = await contextValue.repository.getStopById(nextOrderedStop.stopId);
|
||||||
if (!nextStopObject) return null;
|
if (!nextStopObject) return null;
|
||||||
|
|
||||||
|
return {
|
||||||
|
route: parent.route,
|
||||||
|
stop: {
|
||||||
|
coordinates: nextStopObject.coordinates as Coordinates,
|
||||||
|
id: nextStopObject.id,
|
||||||
|
name: nextStopObject.name,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
previousStop: async (parent, args, contextValue, info): Promise<OrderedStop | null> => {
|
||||||
|
const routeId = parent.route.id;
|
||||||
|
const stopId = parent.stop.id;
|
||||||
|
|
||||||
|
const currentOrderedStop = await contextValue.repository.getOrderedStopByRouteAndStopId(routeId, stopId);
|
||||||
|
if (!currentOrderedStop) return null;
|
||||||
|
|
||||||
|
const previousOrderedStop = currentOrderedStop.previousStop;
|
||||||
|
if (!previousOrderedStop) return null;
|
||||||
|
|
||||||
|
const nextStopObject = await contextValue.repository.getStopById(previousOrderedStop.stopId);
|
||||||
|
if (!nextStopObject) return null;
|
||||||
|
|
||||||
return {
|
return {
|
||||||
route: parent.route,
|
route: parent.route,
|
||||||
stop: {
|
stop: {
|
||||||
|
|||||||
Reference in New Issue
Block a user