Refactor code structure and dependencies

- Remove unused files and modules
- Update submodule URL for epess-database
- Update DATABASE_URL in compose.yaml
- Update CI workflow to fetch submodules during checkout and fix GITHUB_TOKEN issue
- Enable strict mode in tsconfig.json
- Add UsersService and UsersResolver in users module
- Remove AppService and AppController
- Update main.ts to remove unused imports and log statement
- Add PrismaModule and PrismaService
- Add PrismaContextMiddleware
- Update GraphQL module to use schema and PrismaService
- Update package.json dependencies and devDependencies
This commit is contained in:
2024-09-27 06:21:04 +07:00
parent 8fe5e62870
commit 258a35d364
23 changed files with 4751 additions and 894 deletions

117
src/graphql/schema.ts Normal file
View File

@@ -0,0 +1,117 @@
import { builder, prisma } from './graphql.builder';
builder.prismaObject('User', {
fields: (t) => ({
id: t.exposeID('id'),
name: t.exposeString('name'),
email: t.exposeString('email'),
phoneNumber: t.exposeString('phoneNumber'),
role: t.exposeString('role'),
createdAt: t.expose('createdAt', {
type: 'DateTime',
}),
updatedAt: t.expose('updatedAt', {
type: 'DateTime',
}),
order: t.relation('orders'),
serviceFeedbacks: t.relation('serviceFeedbacks'),
documents: t.relation('documents'),
sendingMessage: t.relation('sendingMessage'),
Service: t.relation('Service'),
center: t.relation('center'),
customerChatRoom: t.relation('customerChatRoom'),
centerStaffChatRoom: t.relation('centerStaffChatRoom'),
CenterStaff: t.relation('CenterStaff'),
WorkshopSubscription: t.relation('WorkshopSubscription'),
}),
});
builder.prismaObject('Order', {
fields: (t) => ({
id: t.exposeID('id'),
userId: t.exposeID('userId'),
}),
});
builder.prismaObject('ServiceFeedback', {
fields: (t) => ({
id: t.exposeID('id'),
userId: t.exposeID('userId'),
}),
});
builder.prismaObject('UploadedDocument', {
name: 'documents',
fields: (t) => ({
id: t.exposeID('id'),
userId: t.exposeID('userId'),
}),
});
builder.prismaObject('Message', {
name: 'sendingMessage',
fields: (t) => ({
id: t.exposeID('id'),
userId: t.exposeID('senderId'),
}),
});
builder.prismaObject('Service', {
fields: (t) => ({
id: t.exposeID('id'),
userId: t.exposeID('userId'),
}),
});
builder.prismaObject('Center', {
fields: (t) => ({
id: t.exposeID('id'),
userId: t.exposeID('centerOwnerId'),
}),
});
builder.prismaObject('ChatRoom', {
fields: (t) => ({
id: t.exposeID('id'),
}),
});
builder.prismaObject('CenterStaff', {
fields: (t) => ({
staffId: t.exposeID('staffId'),
centerId: t.exposeID('centerId'),
serviceId: t.exposeID('serviceId'),
}),
});
builder.prismaObject('WorkshopSubscription', {
fields: (t) => ({
userId: t.exposeID('userId'),
workshopId: t.exposeID('workshopId'),
user: t.relation('user'),
workshop: t.relation('workshop'),
}),
});
builder.prismaObject('Workshop', {
fields: (t) => ({
id: t.exposeID('id'),
}),
});
// Query section
builder.queryType({
fields: (t) => ({
users: t.prismaField({
type: ['User'], // Return type is a list of 'User'
resolve: (query, root, args, ctx, info) => {
return prisma.user.findMany({
...query,
// Include related posts in the query
});
},
}),
}),
});
export const schema = builder.toSchema();