move parking structures to a sub-field of system

This commit is contained in:
2025-04-16 17:01:41 -07:00
parent cb05d3ca03
commit 544cab5324
6 changed files with 187 additions and 141 deletions

View File

@@ -0,0 +1,29 @@
import { Resolvers } from "../generated/graphql";
import { ServerContext } from "../ServerContext";
export const ParkingSystemResolvers: Resolvers<ServerContext> = {
ParkingSystem: {
parkingStructures: async (parent, _args, contextValue, _info) => {
const system = contextValue.findSystemById(parent.systemId);
if (!system) {
return [];
}
const parkingRepository = system.parkingRepository;
if (!parkingRepository) return [];
return await parkingRepository.getParkingStructures();
},
parkingStructure: async (parent, args, contextValue, info) => {
if (!args.id) return null;
const system = contextValue.findSystemById(parent.systemId);
if (!system) {
return null;
}
const parkingRepository = system.parkingRepository;
if (!parkingRepository) return null;
return await parkingRepository.getParkingStructureById(args.id);
},
}
}