push code ne
This commit is contained in:
89
src/AdminNote/adminnote.schema.ts
Normal file
89
src/AdminNote/adminnote.schema.ts
Normal file
@@ -0,0 +1,89 @@
|
||||
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 AdminNoteSchema extends PothosSchema {
|
||||
constructor(
|
||||
@Inject(SchemaBuilderToken) private readonly builder: Builder,
|
||||
private readonly prisma: PrismaService,
|
||||
) {
|
||||
super();
|
||||
}
|
||||
|
||||
@PothosRef()
|
||||
adminNote() {
|
||||
return this.builder.prismaObject('AdminNote', {
|
||||
description: 'An admin note.',
|
||||
fields: (t) => ({
|
||||
id: t.exposeID('id', {
|
||||
description: 'The ID of the admin note.',
|
||||
}),
|
||||
content: t.exposeString('content', {
|
||||
description: 'The content of the admin note.',
|
||||
}),
|
||||
notedByUserId: t.exposeString('notedByUserId', {
|
||||
description: 'The ID of the user who created the admin note.',
|
||||
}),
|
||||
notedBy: t.relation('notedBy', {
|
||||
description: 'The user who created the admin note.',
|
||||
}),
|
||||
createdAt: t.expose('createdAt', {
|
||||
type: 'DateTime',
|
||||
description: 'The date and time the admin note was created.',
|
||||
}),
|
||||
updatedAt: t.expose('updatedAt', {
|
||||
type: 'DateTime',
|
||||
description: 'The date and time the admin note was last updated.',
|
||||
}),
|
||||
center: t.relation('center', {
|
||||
description: 'The center the admin note is associated with.',
|
||||
}),
|
||||
service: t.relation('service', {
|
||||
description: 'The service the admin note is associated with.',
|
||||
}),
|
||||
serviceId: t.exposeString('serviceId', {
|
||||
description:
|
||||
'The ID of the service the admin note is associated with.',
|
||||
}),
|
||||
}),
|
||||
});
|
||||
}
|
||||
|
||||
@Pothos()
|
||||
init(): void {
|
||||
this.builder.queryFields((t) => ({
|
||||
adminNote: t.prismaField({
|
||||
type: this.adminNote(),
|
||||
args: this.builder.generator.findUniqueArgs('AdminNote'),
|
||||
description: 'Retrieve a single admin note by its unique identifier.',
|
||||
resolve: async (query, root, args, ctx, info) => {
|
||||
return await this.prisma.adminNote.findUnique({
|
||||
...query,
|
||||
where: args.where,
|
||||
});
|
||||
},
|
||||
}),
|
||||
adminNotes: t.prismaField({
|
||||
type: [this.adminNote()],
|
||||
args: this.builder.generator.findManyArgs('AdminNote'),
|
||||
description: 'Retrieve a list of admin notes.',
|
||||
resolve: async (query, root, args, ctx, info) => {
|
||||
return await this.prisma.adminNote.findMany({
|
||||
...query,
|
||||
where: args.filter ?? undefined,
|
||||
orderBy: args.orderBy ?? undefined,
|
||||
skip: args.skip ?? undefined,
|
||||
take: args.take ?? undefined,
|
||||
});
|
||||
},
|
||||
}),
|
||||
}));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user