createRoom.js
865 Bytes
import { prisma } from "../../../utils";
export default {
Mutation: {
createRoom: async (_, args) => {
const { participantsId, categories } = args;
let newRoom, participantId;
if (participantsId !== undefined) {
newRoom = await prisma.room.create({
data: {
participants: {
connect: {
id: (participantId = participantsId.forEach(
(cur, _, __) => cur
)),
},
},
},
});
}
if (categories !== undefined) {
newRoom = await prisma.room.create({
data: {
categories: {
connect: {
id: (category = categories.forEach((cur, _, __) => cur)),
},
},
},
});
}
return newRoom;
},
},
};