fix getting item ancestors

master
Lauren Liberda 2021-07-17 17:07:19 +02:00
parent bf85f181ea
commit c894da4449
2 changed files with 4 additions and 3 deletions

View File

@ -22,7 +22,6 @@ export class ItemsResolver {
@ResolveField()
async parent(@Parent() item: ItemModel) {
if (item.parent) return item.parent;
return this.itemsService.getItemParent(item);
}

View File

@ -22,8 +22,10 @@ export class ItemsService {
}
async getItemParent(item: ItemModel) {
const itemE = await this.itemRepository.findOneOrFail(item.id);
return (await this.treeRepository.findAncestorsTree(itemE)).parent;
const childItem = await this.itemRepository.findOneOrFail(item.id, {
relations: ['parent'],
});
return childItem.parent;
}
async createItem(input: NewItemInput): Promise<Item> {