sdy

update createRoom resolver and typedef

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