From a49cd8500c011d21bd508fd2ac364e7c49e3a658 Mon Sep 17 00:00:00 2001 From: keyan Date: Fri, 15 Apr 2022 11:51:49 -0500 Subject: [PATCH] add nComments resolver --- api/resolvers/item.js | 5 +++++ api/typeDefs/item.js | 1 + 2 files changed, 6 insertions(+) diff --git a/api/resolvers/item.js b/api/resolvers/item.js index a8c28569..e2d247e9 100644 --- a/api/resolvers/item.js +++ b/api/resolvers/item.js @@ -759,6 +759,11 @@ export default { return sats || 0 }, + meComments: async (item, args, { me, models }) => { + if (!me) return 0 + + return await models.items.count({ where: { userId: me.id, parentId: item.id } }) + }, mine: async (item, args, { me, models }) => { return me?.id === item.userId }, diff --git a/api/typeDefs/item.js b/api/typeDefs/item.js index edc5d40f..f0ebe2d4 100644 --- a/api/typeDefs/item.js +++ b/api/typeDefs/item.js @@ -60,6 +60,7 @@ export default gql` sats: Int! upvotes: Int! meSats: Int! + meComments: Int! ncomments: Int! comments: [Item!]! path: String