sdy

remove unnecessary files

import { prisma } from "../../utils";
export default {
Room: {
categories: (parent) =>
prisma.room.findOne({ where: { id: parent.id } }).categories(),
messages: (parent) =>
prisma.room.findOne({ where: { id: parent.id } }).messages(),
participants: (parent) =>
prisma.room.findOne({ where: { id: parent.id } }).participants(),
},
};
type Mutation {
createRoom(name: String!): Room!
}
import { prisma, isAuthenticated } from "../../../utils";
export default {
Mutation: {
createRoom: async (_, args, { request }) => {
isAuthenticated(request);
const { name } = args;
const { user } = request;
let newRoom;
if (name !== undefined) {
newRoom = await prisma.room.create({
data: {
name,
participants: {
connect: {
id: user.id,
},
},
},
});
}
return newRoom;
},
},
};
type Query {
getRoomByName(roomName: String!): Room!
}
import { prisma, isAuthenticated } from "../../../utils";
export default {
Query: {
getRoomByName: async (_, args, { request }) => {
isAuthenticated(request);
const { roomName } = args;
return prisma.room.findOne({
where: {
name: roomName,
},
});
},
},
};
import { prisma } from "../../../utils";
export default {
Query: {
getRooms: async () => {
return prisma.room.findMany();
},
},
};