diff --git a/src/UploadedDocument/uploadeddocument.module.ts b/src/UploadedDocument/uploadeddocument.module.ts new file mode 100644 index 0000000..ce4f8f8 --- /dev/null +++ b/src/UploadedDocument/uploadeddocument.module.ts @@ -0,0 +1,9 @@ +import { Module, Global } from '@nestjs/common'; +import { UploadedDocumentSchema } from './uploadeddocument.schema'; + +@Global() +@Module({ + providers: [UploadedDocumentSchema], + exports: [UploadedDocumentSchema], +}) +export class UploadedDocumentModule {} diff --git a/src/UploadedDocument/uploadeddocument.schema.ts b/src/UploadedDocument/uploadeddocument.schema.ts new file mode 100644 index 0000000..068d189 --- /dev/null +++ b/src/UploadedDocument/uploadeddocument.schema.ts @@ -0,0 +1,64 @@ +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 UploadedDocumentSchema extends PothosSchema { + constructor( + @Inject(SchemaBuilderToken) private readonly builder: Builder, + private readonly prisma: PrismaService, + ) { + super(); + } + + @PothosRef() + uploadedDocument() { + return this.builder.prismaObject('UploadedDocument', { + fields: (t) => ({ + id: t.exposeID('id'), + userId: t.exposeID('userId'), + documentName: t.exposeString('documentName'), + documentType: t.exposeString('documentType'), + status: t.exposeString('status'), + type: t.exposeString('type'), + documentUrl: t.exposeString('documentUrl'), + uploadedAt: t.expose('uploadedAt', { type: 'DateTime' as any }), + }), + }); + } + + @Pothos() + init(): void { + this.builder.queryFields((t) => ({ + uploadedDocument: t.prismaField({ + type: this.uploadedDocument(), + args: this.builder.generator.findUniqueArgs('UploadedDocument'), + resolve: async (query, root, args, ctx, info) => { + return await this.prisma.uploadedDocument.findUnique({ + ...query, + where: args.where, + }); + }, + }), + uploadedDocuments: t.prismaField({ + type: [this.uploadedDocument()], + args: this.builder.generator.findManyArgs('UploadedDocument'), + resolve: async (query, root, args, ctx, info) => { + return await this.prisma.uploadedDocument.findMany({ + ...query, + skip: args.skip ?? 0, + take: args.take ?? 10, + orderBy: args.orderBy ?? undefined, + where: args.filter ?? undefined, + }); + }, + }), + })); + } +} diff --git a/src/WorkshopMeetingRoom/workshopmeetingroom.module.ts b/src/WorkshopMeetingRoom/workshopmeetingroom.module.ts new file mode 100644 index 0000000..d40ac24 --- /dev/null +++ b/src/WorkshopMeetingRoom/workshopmeetingroom.module.ts @@ -0,0 +1,9 @@ +import { Module, Global } from '@nestjs/common'; +import { WorkshopMeetingRoomSchema } from './workshopmeetingroom.schema'; + +@Global() +@Module({ + providers: [WorkshopMeetingRoomSchema], + exports: [WorkshopMeetingRoomSchema], +}) +export class WorkshopMeetingRoomModule {} diff --git a/src/WorkshopMeetingRoom/workshopmeetingroom.schema.ts b/src/WorkshopMeetingRoom/workshopmeetingroom.schema.ts new file mode 100644 index 0000000..d04504c --- /dev/null +++ b/src/WorkshopMeetingRoom/workshopmeetingroom.schema.ts @@ -0,0 +1,29 @@ +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 WorkshopMeetingRoomSchema extends PothosSchema { + constructor( + @Inject(SchemaBuilderToken) private readonly builder: Builder, + private readonly prisma: PrismaService, + ) { + super(); + } + + @PothosRef() + workshopMeetingRoom() { + return this.builder.prismaObject('WorkshopMeetingRoom', { + fields: (t) => ({ + id: t.exposeID('id'), + workshopId: t.exposeID('workshopId'), + }), + }); + } +} diff --git a/src/graphql/graphql.module.ts b/src/graphql/graphql.module.ts index 3400933..98e711e 100644 --- a/src/graphql/graphql.module.ts +++ b/src/graphql/graphql.module.ts @@ -27,6 +27,7 @@ import { MilestoneModule } from '../Milestone/milestone.module'; import { ScheduleModule } from '../Schedule/schedule.module'; import { MessageModule } from '../Message/message.module'; import { ServiceMeetingRoomModule } from '../ServiceMeetingRoom/servicemeetingroom.module'; +import { UploadedDocumentModule } from '../UploadedDocument/uploadeddocument.module'; @Global() @Module({ imports: [ @@ -50,6 +51,7 @@ import { ServiceMeetingRoomModule } from '../ServiceMeetingRoom/servicemeetingro ScheduleModule, MessageModule, ServiceMeetingRoomModule, + UploadedDocumentModule, PothosModule.forRoot({ builder: { inject: [PrismaService], diff --git a/src/workshopsubscription/workshopsubscription.schema.ts b/src/workshopsubscription/workshopsubscription.schema.ts index 32d13f6..b629df0 100644 --- a/src/workshopsubscription/workshopsubscription.schema.ts +++ b/src/workshopsubscription/workshopsubscription.schema.ts @@ -27,4 +27,33 @@ export class WorkshopSubscriptionSchema extends PothosSchema { }), }); } + + @Pothos() + init(): void { + this.builder.queryFields((t) => ({ + workshopSubscription: t.prismaField({ + type: this.workshopSubscription(), + args: this.builder.generator.findUniqueArgs('WorkshopSubscription'), + resolve: async (query, root, args, ctx, info) => { + return await this.prisma.workshopSubscription.findUnique({ + ...query, + where: args.where, + }); + }, + }), + workshopSubscriptions: t.prismaField({ + type: [this.workshopSubscription()], + args: this.builder.generator.findManyArgs('WorkshopSubscription'), + resolve: async (query, root, args, ctx, info) => { + return await this.prisma.workshopSubscription.findMany({ + ...query, + skip: args.skip ?? 0, + take: args.take ?? 10, + orderBy: args.orderBy ?? undefined, + where: args.filter ?? undefined, + }); + }, + }), + })); + } }