sdy

update createRoom

1 +type Mutation {
2 + createRoom(participantsId: [Int], categories: [Int]): Room!
3 +}
1 +import { prisma } from "../../../utils";
2 +
3 +export default {
4 + Mutation: {
5 + createRoom: async (_, args) => {
6 + const { participantsId, categories } = args;
7 + let newRoom, participantId;
8 + if (participantsId !== undefined) {
9 + newRoom = await prisma.room.create({
10 + data: {
11 + participants: {
12 + connect: {
13 + id: (participantId = participantsId.forEach(
14 + (cur, _, __) => cur
15 + )),
16 + },
17 + },
18 + },
19 + });
20 + }
21 + if (categories !== undefined) {
22 + newRoom = await prisma.room.create({
23 + data: {
24 + categories: {
25 + connect: {
26 + id: (category = categories.forEach((cur, _, __) => cur)),
27 + },
28 + },
29 + },
30 + });
31 + }
32 + return newRoom;
33 + },
34 + },
35 +};