sdy

remove unnecessary files

1 -import { prisma } from "../../utils";
2 -
3 -export default {
4 - Category: {
5 - messages: (parent) =>
6 - prisma.category.findOne({ where: { id: parent.id } }).messages(),
7 - },
8 -};
1 -type Mutation {
2 - addCategory(name: String): Category!
3 -}
1 -import { prisma, isAuthenticated } from "../../../utils";
2 -import { NEW_CATEGORY } from "../../../topics";
3 -
4 -export default {
5 - Mutation: {
6 - addCategory: async (_, args, { request, pubsub }) => {
7 - isAuthenticated(request);
8 - const { name } = args;
9 - const newCategory = await prisma.category.create({
10 - data: {
11 - name,
12 - },
13 - });
14 - if (newCategory !== undefined) {
15 - pubsub.publish(NEW_CATEGORY, { subCategory: newCategory });
16 - }
17 - return newCategory;
18 - },
19 - },
20 -};
1 -type Mutation {
2 - deleteCategory(name: String!): Boolean!
3 -}
1 -import { prisma } from "../../../utils";
2 -
3 -export default {
4 - Mutation: {
5 - deleteCategory: async (_, args) => {
6 - const { name } = args;
7 - return prisma.category.delete({
8 - where: {
9 - name,
10 - },
11 - });
12 - },
13 - },
14 -};
1 -type Query {
2 - getCategories: [Category]
3 -}
1 -import { prisma } from "../../../utils";
2 -
3 -export default {
4 - Query: {
5 - getCategories: async (_, __) => {
6 - return prisma.category.findMany();
7 - },
8 - },
9 -};
1 -type Subscription {
2 - subCategory: Category
3 -}
1 -import { NEW_CATEGORY } from "../../../topics";
2 -
3 -export default {
4 - Subscription: {
5 - subCategory: {
6 - subscribe: async (_, __, { pubsub }) => {
7 - return pubsub.asyncIterator(NEW_CATEGORY);
8 - },
9 - },
10 - },
11 -};