mirror of
https://github.com/brendan-ch/project-inter-server.git
synced 2026-04-16 23:40:32 +00:00
Add system ID to parking structure
This commit is contained in:
@@ -30,6 +30,7 @@ type ParkingStructure {
|
||||
coordinates: Coordinates!
|
||||
address: String!
|
||||
updatedTime: DateTime
|
||||
systemId: ID!
|
||||
|
||||
historicalAverages(input: HistoricalParkingAverageQueryInput): [HistoricalParkingAverageQueryResult!]
|
||||
}
|
||||
|
||||
@@ -11,9 +11,15 @@ export const ParkingSystemResolvers: Resolvers<ServerContext> = {
|
||||
const parkingRepository = system.parkingRepository;
|
||||
if (!parkingRepository) return [];
|
||||
|
||||
return await parkingRepository.getParkingStructures();
|
||||
const parkingStructures = await parkingRepository.getParkingStructures();
|
||||
return parkingStructures.map((structure) => {
|
||||
return {
|
||||
...structure,
|
||||
systemId: parent.systemId
|
||||
};
|
||||
});
|
||||
},
|
||||
parkingStructure: async (parent, args, contextValue, info) => {
|
||||
parkingStructure: async (parent, args, contextValue, _info) => {
|
||||
if (!args.id) return null;
|
||||
|
||||
const system = contextValue.findSystemById(parent.systemId);
|
||||
@@ -23,7 +29,11 @@ export const ParkingSystemResolvers: Resolvers<ServerContext> = {
|
||||
const parkingRepository = system.parkingRepository;
|
||||
if (!parkingRepository) return null;
|
||||
|
||||
return await parkingRepository.getParkingStructureById(args.id);
|
||||
const parkingStructure = await parkingRepository.getParkingStructureById(args.id);
|
||||
return parkingStructure ? {
|
||||
...parkingStructure,
|
||||
systemId: parent.systemId,
|
||||
} : null;
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user