sdy

remove unnecessary files

import { prisma } from "../../utils";
export default {
Category: {
messages: (parent) =>
prisma.category.findOne({ where: { id: parent.id } }).messages(),
},
};
type Mutation {
addCategory(name: String): Category!
}
import { prisma, isAuthenticated } from "../../../utils";
import { NEW_CATEGORY } from "../../../topics";
export default {
Mutation: {
addCategory: async (_, args, { request, pubsub }) => {
isAuthenticated(request);
const { name } = args;
const newCategory = await prisma.category.create({
data: {
name,
},
});
if (newCategory !== undefined) {
pubsub.publish(NEW_CATEGORY, { subCategory: newCategory });
}
return newCategory;
},
},
};
type Mutation {
deleteCategory(name: String!): Boolean!
}
import { prisma } from "../../../utils";
export default {
Mutation: {
deleteCategory: async (_, args) => {
const { name } = args;
return prisma.category.delete({
where: {
name,
},
});
},
},
};
import { prisma } from "../../../utils";
export default {
Query: {
getCategories: async (_, __) => {
return prisma.category.findMany();
},
},
};
type Subscription {
subCategory: Category
}
import { NEW_CATEGORY } from "../../../topics";
export default {
Subscription: {
subCategory: {
subscribe: async (_, __, { pubsub }) => {
return pubsub.asyncIterator(NEW_CATEGORY);
},
},
},
};