Fixing file name casing
This commit is contained in:
9
src/ChatRoom/chatroom.module.ts
Normal file
9
src/ChatRoom/chatroom.module.ts
Normal 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 {}
|
||||
68
src/ChatRoom/chatroom.schema.ts
Normal file
68
src/ChatRoom/chatroom.schema.ts
Normal 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,
|
||||
});
|
||||
},
|
||||
}),
|
||||
}));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user