add system ID as parent ID in system resolvers

This commit is contained in:
2025-04-06 11:28:13 -07:00
parent bc598f0858
commit 472b3a0b05

View File

@@ -3,7 +3,7 @@ import { ServerContext } from "../ServerContext";
export const SystemResolvers: Resolvers<ServerContext> = { export const SystemResolvers: Resolvers<ServerContext> = {
System: { System: {
routes: async (parent, args, contextValue, info) => { routes: async (parent, args, contextValue, _info) => {
const system = contextValue.systems.find((system) => system.id === parent.id); const system = contextValue.systems.find((system) => system.id === parent.id);
if (!system) { if (!system) {
return []; return [];
@@ -11,7 +11,7 @@ export const SystemResolvers: Resolvers<ServerContext> = {
return await system.shuttleRepository.getRoutesBySystemId(parent.id); return await system.shuttleRepository.getRoutesBySystemId(parent.id);
}, },
stops: async (parent, args, contextValue, info) => { stops: async (parent, args, contextValue, _info) => {
const system = contextValue.systems.find((system) => system.id === parent.id); const system = contextValue.systems.find((system) => system.id === parent.id);
if (!system) { if (!system) {
return []; return [];
@@ -19,7 +19,7 @@ export const SystemResolvers: Resolvers<ServerContext> = {
return await system.shuttleRepository.getStopsBySystemId(parent.id); return await system.shuttleRepository.getStopsBySystemId(parent.id);
}, },
stop: async (parent, args, contextValue, info) => { stop: async (parent, args, contextValue, _info) => {
if (!args.id) return null; if (!args.id) return null;
const system = contextValue.systems.find((system) => system.id === parent.id); const system = contextValue.systems.find((system) => system.id === parent.id);
if (!system) { if (!system) {
@@ -35,9 +35,10 @@ export const SystemResolvers: Resolvers<ServerContext> = {
id: stop.id, id: stop.id,
name: stop.name, name: stop.name,
coordinates: stop.coordinates as Coordinates, coordinates: stop.coordinates as Coordinates,
systemId: parent.id,
}; };
}, },
route: async (parent, args, contextValue, info) => { route: async (parent, args, contextValue, _info) => {
if (!args.id) return null; if (!args.id) return null;
const system = contextValue.systems.find((system) => system.id === parent.id); const system = contextValue.systems.find((system) => system.id === parent.id);
if (!system) { if (!system) {
@@ -53,9 +54,10 @@ export const SystemResolvers: Resolvers<ServerContext> = {
id: route.id, id: route.id,
name: route.name, name: route.name,
polylineCoordinates: route.polylineCoordinates as Coordinates[], polylineCoordinates: route.polylineCoordinates as Coordinates[],
systemId: parent.id,
}; };
}, },
shuttle: async (parent, args, contextValue, info) => { shuttle: async (parent, args, contextValue, _info) => {
if (!args.id) return null; if (!args.id) return null;
const system = contextValue.systems.find((system) => system.id === parent.id); const system = contextValue.systems.find((system) => system.id === parent.id);
if (!system) { if (!system) {
@@ -68,7 +70,7 @@ export const SystemResolvers: Resolvers<ServerContext> = {
return shuttle; return shuttle;
}, },
shuttles: async (parent, args, contextValue, info) => { shuttles: async (parent, args, contextValue, _info) => {
const system = contextValue.systems.find((system) => system.id === parent.id); const system = contextValue.systems.find((system) => system.id === parent.id);
if (!system) { if (!system) {
return []; return [];