From c90eb055c7ef5cb911b4f2ec53a685e383c9aafb Mon Sep 17 00:00:00 2001 From: keyan Date: Mon, 3 Jun 2024 16:50:38 -0500 Subject: [PATCH] fix performance of sub nested resolvers --- api/resolvers/sub.js | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/api/resolvers/sub.js b/api/resolvers/sub.js index 15c19088..dcfab665 100644 --- a/api/resolvers/sub.js +++ b/api/resolvers/sub.js @@ -382,7 +382,10 @@ export default { return await models.user.findUnique({ where: { id: sub.userId } }) }, meMuteSub: async (sub, args, { models }) => { - return sub.meMuteSub || sub.MuteSub?.length > 0 + if (sub.meMuteSub !== undefined) { + return sub.meMuteSub + } + return sub.MuteSub?.length > 0 }, nposts: async (sub, { when, from, to }, { models }) => { if (typeof sub.nposts !== 'undefined') { @@ -395,7 +398,11 @@ export default { } }, meSubscription: async (sub, args, { me, models }) => { - return sub.meSubscription || sub.SubSubscription?.length > 0 + if (sub.meSubscription !== undefined) { + return sub.meSubscription + } + + return sub.SubSubscription?.length > 0 }, createdAt: sub => sub.createdAt || sub.created_at }