mirror of
https://github.com/brendan-ch/project-inter-server.git
synced 2026-04-17 07:50:31 +00:00
update resolvers to pull eta data from apiBasedRepository
This commit is contained in:
@@ -132,10 +132,10 @@ export const resolvers: Resolvers<ServerContext> = {
|
|||||||
Shuttle: {
|
Shuttle: {
|
||||||
eta: async (parent, args, contextValue, info) => {
|
eta: async (parent, args, contextValue, info) => {
|
||||||
if (!args.forStopId) return null;
|
if (!args.forStopId) return null;
|
||||||
const etaForStopId = await contextValue.repository.getEtaForShuttleAndStopId(parent.id, args.forStopId);
|
const etaForStopId = await contextValue.apiBasedRepository.getEtaForShuttleAndStopId(parent.id, args.forStopId);
|
||||||
if (etaForStopId === null) return null;
|
if (etaForStopId === null) return null;
|
||||||
|
|
||||||
const stop = await contextValue.repository.getStopById(etaForStopId.stopId);
|
const stop = await contextValue.apiBasedRepository.getStopById(etaForStopId.stopId);
|
||||||
if (stop === null) return null;
|
if (stop === null) return null;
|
||||||
|
|
||||||
return {
|
return {
|
||||||
@@ -149,14 +149,14 @@ export const resolvers: Resolvers<ServerContext> = {
|
|||||||
};
|
};
|
||||||
},
|
},
|
||||||
etas: async (parent, args, contextValue, info) => {
|
etas: async (parent, args, contextValue, info) => {
|
||||||
const etasForShuttle = await contextValue.repository.getEtasForShuttleId(parent.id);
|
const etasForShuttle = await contextValue.apiBasedRepository.getEtasForShuttleId(parent.id);
|
||||||
if (!etasForShuttle) return null;
|
if (!etasForShuttle) return null;
|
||||||
|
|
||||||
const computedEtas = await Promise.all(etasForShuttle.map(async ({
|
const computedEtas = await Promise.all(etasForShuttle.map(async ({
|
||||||
secondsRemaining,
|
secondsRemaining,
|
||||||
stopId,
|
stopId,
|
||||||
}): Promise<Eta | null> => {
|
}): Promise<Eta | null> => {
|
||||||
const stop = await contextValue.repository.getStopById(stopId);
|
const stop = await contextValue.apiBasedRepository.getStopById(stopId);
|
||||||
if (stop === null) return null;
|
if (stop === null) return null;
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
|||||||
Reference in New Issue
Block a user