Showing
7 changed files
with
0 additions
and
70 deletions
back/src/api/Room/Room.js
deleted
100644 → 0
| 1 | -import { prisma } from "../../utils"; | ||
| 2 | - | ||
| 3 | -export default { | ||
| 4 | - Room: { | ||
| 5 | - categories: (parent) => | ||
| 6 | - prisma.room.findOne({ where: { id: parent.id } }).categories(), | ||
| 7 | - messages: (parent) => | ||
| 8 | - prisma.room.findOne({ where: { id: parent.id } }).messages(), | ||
| 9 | - participants: (parent) => | ||
| 10 | - prisma.room.findOne({ where: { id: parent.id } }).participants(), | ||
| 11 | - }, | ||
| 12 | -}; |
| 1 | -import { prisma, isAuthenticated } from "../../../utils"; | ||
| 2 | - | ||
| 3 | -export default { | ||
| 4 | - Mutation: { | ||
| 5 | - createRoom: async (_, args, { request }) => { | ||
| 6 | - isAuthenticated(request); | ||
| 7 | - const { name } = args; | ||
| 8 | - const { user } = request; | ||
| 9 | - let newRoom; | ||
| 10 | - if (name !== undefined) { | ||
| 11 | - newRoom = await prisma.room.create({ | ||
| 12 | - data: { | ||
| 13 | - name, | ||
| 14 | - participants: { | ||
| 15 | - connect: { | ||
| 16 | - id: user.id, | ||
| 17 | - }, | ||
| 18 | - }, | ||
| 19 | - }, | ||
| 20 | - }); | ||
| 21 | - } | ||
| 22 | - return newRoom; | ||
| 23 | - }, | ||
| 24 | - }, | ||
| 25 | -}; |
| 1 | -import { prisma, isAuthenticated } from "../../../utils"; | ||
| 2 | - | ||
| 3 | -export default { | ||
| 4 | - Query: { | ||
| 5 | - getRoomByName: async (_, args, { request }) => { | ||
| 6 | - isAuthenticated(request); | ||
| 7 | - const { roomName } = args; | ||
| 8 | - return prisma.room.findOne({ | ||
| 9 | - where: { | ||
| 10 | - name: roomName, | ||
| 11 | - }, | ||
| 12 | - }); | ||
| 13 | - }, | ||
| 14 | - }, | ||
| 15 | -}; |
-
Please register or login to post a comment