mirror of
https://github.com/brendan-ch/project-inter-server.git
synced 2026-04-17 07:50:31 +00:00
30 lines
945 B
TypeScript
30 lines
945 B
TypeScript
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);
|
|
},
|
|
}
|
|
}
|