Fixing file name casing
This commit is contained in:
70
src/Resume/resume.schema.ts
Normal file
70
src/Resume/resume.schema.ts
Normal file
@@ -0,0 +1,70 @@
|
||||
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 ResumeSchema extends PothosSchema {
|
||||
constructor(
|
||||
@Inject(SchemaBuilderToken) private readonly builder: Builder,
|
||||
private readonly prisma: PrismaService,
|
||||
) {
|
||||
super();
|
||||
}
|
||||
|
||||
@PothosRef()
|
||||
resume() {
|
||||
return this.builder.prismaObject('Resume', {
|
||||
fields: (t) => ({
|
||||
id: t.exposeID('id'),
|
||||
userId: t.exposeID('userId'),
|
||||
centerId: t.exposeID('centerId'),
|
||||
status: t.exposeString('status'),
|
||||
createdAt: t.expose('createdAt', {
|
||||
type: 'DateTime',
|
||||
nullable: true,
|
||||
}),
|
||||
updatedAt: t.expose('updatedAt', {
|
||||
type: 'DateTime',
|
||||
nullable: true,
|
||||
}),
|
||||
center: t.relation('center'),
|
||||
}),
|
||||
});
|
||||
}
|
||||
|
||||
@Pothos()
|
||||
init(): void {
|
||||
this.builder.queryFields((t) => ({
|
||||
resumes: t.prismaField({
|
||||
type: [this.resume()],
|
||||
args: this.builder.generator.findManyArgs('Resume'),
|
||||
resolve: async (query, root, args, ctx, info) => {
|
||||
return await this.prisma.resume.findMany({
|
||||
...query,
|
||||
skip: args.skip ?? undefined,
|
||||
take: args.take ?? 10,
|
||||
orderBy: args.orderBy ?? undefined,
|
||||
where: args.filter ?? undefined,
|
||||
});
|
||||
},
|
||||
}),
|
||||
|
||||
resume: t.prismaField({
|
||||
type: this.resume(),
|
||||
args: this.builder.generator.findUniqueArgs('Resume'),
|
||||
resolve: async (query, root, args, ctx, info) => {
|
||||
return await this.prisma.resume.findUnique({
|
||||
...query,
|
||||
where: args.where,
|
||||
});
|
||||
},
|
||||
}),
|
||||
}));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user