sdy

remove unnecessary files

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 -type Mutation {
2 - createRoom(name: String!): Room!
3 -}
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 -type Query {
2 - getRoomByName(roomName: String!): Room!
3 -}
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 -};
1 -type Query {
2 - getRooms: [Room]
3 -}
1 -import { prisma } from "../../../utils";
2 -
3 -export default {
4 - Query: {
5 - getRooms: async () => {
6 - return prisma.room.findMany();
7 - },
8 - },
9 -};