Refactor code structure and dependencies

This commit is contained in:
2024-09-27 06:51:14 +07:00
parent 258a35d364
commit 6cc26c0f75
7 changed files with 676 additions and 16 deletions

View File

@@ -1,4 +1,5 @@
import { builder, prisma } from './graphql.builder';
import type PrismaTypes from '@pothos/plugin-prisma/generated';
builder.prismaObject('User', {
fields: (t) => ({
@@ -9,9 +10,11 @@ builder.prismaObject('User', {
role: t.exposeString('role'),
createdAt: t.expose('createdAt', {
type: 'DateTime',
nullable: true,
}),
updatedAt: t.expose('updatedAt', {
type: 'DateTime',
nullable: true,
}),
order: t.relation('orders'),
serviceFeedbacks: t.relation('serviceFeedbacks'),
@@ -114,4 +117,40 @@ builder.queryType({
}),
});
// // Mutation section
// builder.mutationType({
// fields: (t) => ({
// createUser: t.prismaField({
// type: 'User',
// args: {
// data: t.arg({
// type: 'PrismaTypes.UserCreateInput',
// }),
// },
// resolve: (query, root, args, ctx, info) => {
// return prisma.user.create({
// data: args.data,
// });
// },
// }),
// }),
// });
// // Subscription section
// builder.subscriptionType({
// fields: (t) => ({
// userCreated: t.prismaField({
// type: 'User',
// subscribe: (query, root, args, ctx, info) => {
// return prisma.$subscribe.user({
// mutation_in: ['CREATED'],
// });
// },
// resolve: (payload) => {
// return payload;
// },
// }),
// }),
// });
export const schema = builder.toSchema();