mirror of
https://github.com/brendan-ch/project-inter-server.git
synced 2026-04-19 08:50:29 +00:00
Add system ID to parking structure
This commit is contained in:
@@ -30,6 +30,7 @@ type ParkingStructure {
|
|||||||
coordinates: Coordinates!
|
coordinates: Coordinates!
|
||||||
address: String!
|
address: String!
|
||||||
updatedTime: DateTime
|
updatedTime: DateTime
|
||||||
|
systemId: ID!
|
||||||
|
|
||||||
historicalAverages(input: HistoricalParkingAverageQueryInput): [HistoricalParkingAverageQueryResult!]
|
historicalAverages(input: HistoricalParkingAverageQueryInput): [HistoricalParkingAverageQueryResult!]
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,9 +11,15 @@ export const ParkingSystemResolvers: Resolvers<ServerContext> = {
|
|||||||
const parkingRepository = system.parkingRepository;
|
const parkingRepository = system.parkingRepository;
|
||||||
if (!parkingRepository) return [];
|
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;
|
if (!args.id) return null;
|
||||||
|
|
||||||
const system = contextValue.findSystemById(parent.systemId);
|
const system = contextValue.findSystemById(parent.systemId);
|
||||||
@@ -23,7 +29,11 @@ export const ParkingSystemResolvers: Resolvers<ServerContext> = {
|
|||||||
const parkingRepository = system.parkingRepository;
|
const parkingRepository = system.parkingRepository;
|
||||||
if (!parkingRepository) return null;
|
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