From ce45574bce3fcab81970f834b7cf8ee5c39335da Mon Sep 17 00:00:00 2001 From: keyan Date: Wed, 10 Jul 2024 19:39:53 -0500 Subject: [PATCH] fix #1261 --- api/resolvers/item.js | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/api/resolvers/item.js b/api/resolvers/item.js index dab28ec4..131d3c50 100644 --- a/api/resolvers/item.js +++ b/api/resolvers/item.js @@ -1155,7 +1155,21 @@ export default { if (item.root) { return item.root } - return await getItem(item, { id: item.rootId }, { me, models }) + + // we can't use getItem because activeOrMine will prevent root from being fetched + const [root] = await itemQueryWithMeta({ + me, + models, + query: ` + ${SELECT} + FROM "Item" + ${whereClause( + '"Item".id = $1', + `("Item"."invoiceActionState" IS NULL OR "Item"."invoiceActionState" = 'PAID' OR "Item"."userId" = ${me.id})` + )}` + }, Number(item.rootId)) + + return root }, invoice: async (item, args, { models }) => { if (item.invoiceId) {