UNPKG

@coko/server

Version:

Reusable server for use by Coko's projects

44 lines 1.59 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); const logger_1 = __importDefault(require("../../logger")); const constants_1 = require("./constants"); const chatChannel_controller_1 = require("./chatChannel.controller"); const { CHAT_CHANNEL_RESOLVER } = constants_1.labels; const chatChannelResolver = async (_, { id }) => { try { logger_1.default.info(`${CHAT_CHANNEL_RESOLVER} getChatChannel`); return (0, chatChannel_controller_1.getChatChannel)(id); } catch (e) { logger_1.default.error(`${CHAT_CHANNEL_RESOLVER} getChatChannel: ${e.message}`); throw e; } }; const chatChannelsResolver = async (_, { filter }) => { try { logger_1.default.info(`${CHAT_CHANNEL_RESOLVER} getChatChannels`); return (0, chatChannel_controller_1.getChatChannels)(filter); } catch (e) { logger_1.default.error(`${CHAT_CHANNEL_RESOLVER} getChatChannels: ${e.message}`); throw e; } }; const channelMessagesResolver = async (chatChannel, _, ctx) => { const { id } = chatChannel; return ctx.loaders.ChatMessage.messagesBasedOnChatChannelIdsLoader.load(id); }; const resolvers = { Query: { chatChannel: chatChannelResolver, chatChannels: chatChannelsResolver, }, ChatChannel: { messages: channelMessagesResolver, }, }; exports.default = resolvers; //# sourceMappingURL=chatChannel.resolvers.js.map