Fixing file name casing

This commit is contained in:
2024-10-12 23:15:06 +07:00
parent 5c40a2fd53
commit 0e3aa751ce
29 changed files with 0 additions and 0 deletions

View File

@@ -0,0 +1,9 @@
import { Global, Module } from '@nestjs/common';
import { ChatroomSchema } from './chatroom.schema';
@Global()
@Module({
providers: [ChatroomSchema],
exports: [ChatroomSchema],
})
export class ChatroomModule {}

View File

@@ -0,0 +1,68 @@
import { Inject, Injectable } from '@nestjs/common';
import {
Pothos,
PothosRef,
PothosSchema,
SchemaBuilderToken,
} from '@smatch-corp/nestjs-pothos';
import { Builder } from '../Graphql/graphql.builder';
import { PrismaService } from '../Prisma/prisma.service';
@Injectable()
export class ChatroomSchema extends PothosSchema {
constructor(
@Inject(SchemaBuilderToken) private readonly builder: Builder,
private readonly prisma: PrismaService,
) {
super();
}
@PothosRef()
chatRoom() {
return this.builder.prismaObject('ChatRoom', {
fields: (t) => ({
id: t.exposeID('id'),
type: t.exposeString('type'),
customerId: t.exposeID('customerId'),
centerId: t.exposeID('centerId'),
centerStaffId: t.exposeID('centerStaffId'),
createdAt: t.expose('createdAt', { type: 'DateTime' }),
message: t.relation('message'),
customer: t.relation('customer'),
center: t.relation('center'),
centerStaff: t.relation('centerStaff'),
meetingRoom: t.relation('meetingRoom'),
}),
});
}
@Pothos()
init(): void {
this.builder.queryFields((t) => ({
chatRoom: t.prismaField({
type: this.chatRoom(),
args: this.builder.generator.findUniqueArgs('ChatRoom'),
resolve: async (query, root, args, ctx, info) => {
return await this.prisma.chatRoom.findUnique({
...query,
where: args.where,
});
},
}),
chatRooms: t.prismaField({
type: [this.chatRoom()],
args: this.builder.generator.findManyArgs('ChatRoom'),
resolve: async (query, root, args, ctx, info) => {
return await this.prisma.chatRoom.findMany({
...query,
skip: args.skip ?? 0,
take: args.take ?? 10,
orderBy: args.orderBy ?? undefined,
where: args.filter ?? undefined,
});
},
}),
}));
}
}