sdy

create seeAllMessage

1 +type Query {
2 + seeAllMessage(roomId: Int!): [Message]
3 +}
1 +import { prisma } from "../../../utils";
2 +
3 +export default {
4 + Query: {
5 + seeAllMessage: async (_, args) => {
6 + const { roomId } = args;
7 + let room, messageList;
8 + try {
9 + room = await prisma.room.findOne({
10 + where: {
11 + id: roomId,
12 + },
13 + });
14 +
15 + if (room !== undefined) {
16 + messageList = await prisma.message.findMany({
17 + where: {
18 + roomId: roomId,
19 + },
20 + });
21 + }
22 + } catch (e) {
23 + console.log(e);
24 + }
25 + return messageList;
26 + },
27 + },
28 +};