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

@@ -3,17 +3,17 @@ import PrismaPlugin from '@pothos/plugin-prisma';
import PrismaUtils from '@pothos/plugin-prisma-utils';
import { DateTimeResolver } from 'graphql-scalars';
import { PrismaService } from '../prisma/prisma.service';
import type PrismaTypes from '@pothos/plugin-prisma/generated';
import { getDatamodel } from '@pothos/plugin-prisma/generated';
import type PrismaTypes from '../types/pothos.generated';
import { getDatamodel } from '../types/pothos.generated';
export const prisma = new PrismaService();
export const prisma = new PrismaService({});
export const builder = new SchemaBuilder<{
Scalars: {
DateTime: {
Input: Date;
Output: Date;
Scalars: {
DateTime: {
Input: Date;
Output: Date;
};
};
};
PrismaTypes: PrismaTypes;
}>({
plugins: [PrismaPlugin, PrismaUtils],

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();

File diff suppressed because one or more lines are too long