fix bug querying depth on restricted zones
This commit is contained in:
parent
caefc6610c
commit
03cde98eae
2 changed files with 12 additions and 4 deletions
|
@ -272,8 +272,15 @@ const resolvers = {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
Zone: {
|
Zone: {
|
||||||
label: async (zone, _, { zoneTranslationLoader }) => {
|
depth: async ({ id }, _, { zoneLoader }) => {
|
||||||
const zoneTranslation = await zoneTranslationLoader.load(zone.id);
|
// TODO: Should we extend this loader-in-field pattern elsewhere? I like
|
||||||
|
// that we avoid the fetch in cases where we only want the zone ID,
|
||||||
|
// but it adds complexity 🤔
|
||||||
|
const zone = await zoneLoader.load(id);
|
||||||
|
return zone.depth;
|
||||||
|
},
|
||||||
|
label: async ({ id }, _, { zoneTranslationLoader }) => {
|
||||||
|
const zoneTranslation = await zoneTranslationLoader.load(id);
|
||||||
return zoneTranslation.label;
|
return zoneTranslation.label;
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
|
@ -256,7 +256,8 @@ const buildZoneLoader = (db) =>
|
||||||
|
|
||||||
return ids.map(
|
return ids.map(
|
||||||
(id) =>
|
(id) =>
|
||||||
entitiesById.get(id) || new Error(`could not find zone with ID: ${id}`)
|
entitiesById.get(String(id)) ||
|
||||||
|
new Error(`could not find zone with ID: ${id}`)
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -273,7 +274,7 @@ const buildZoneTranslationLoader = (db) =>
|
||||||
|
|
||||||
return zoneIds.map(
|
return zoneIds.map(
|
||||||
(zoneId) =>
|
(zoneId) =>
|
||||||
entitiesByZoneId.get(zoneId) ||
|
entitiesByZoneId.get(String(zoneId)) ||
|
||||||
new Error(`could not find translation for zone ${zoneId}`)
|
new Error(`could not find translation for zone ${zoneId}`)
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in a new issue