add centerstaff mutation

This commit is contained in:
2024-10-13 19:38:51 +07:00
parent 1f86786e1a
commit 75a10356da
7 changed files with 99 additions and 25 deletions

View File

@@ -49,5 +49,61 @@ export class CenterStaffSchema extends PothosSchema {
},
}),
}));
// mutations
this.builder.mutationFields((t) => ({
createCenterStaff: t.prismaField({
type: this.centerStaff(),
args: {
data: t.arg({
type: this.builder.generator.getCreateInput('CenterStaff'),
required: true,
}),
},
resolve: async (query, root, args, ctx, info) => {
return await this.prisma.centerStaff.create({
...query,
data: args.data,
});
},
}),
updateCenterStaff: t.prismaField({
type: this.centerStaff(),
args: {
where: t.arg({
type: this.builder.generator.getWhereUnique('CenterStaff'),
required: true,
}),
data: t.arg({
type: this.builder.generator.getUpdateInput('CenterStaff'),
required: true,
}),
},
resolve: async (query, root, args, ctx, info) => {
return await this.prisma.centerStaff.update({
...query,
where: args.where,
data: args.data,
});
},
}),
deleteCenterStaff: t.prismaField({
type: this.centerStaff(),
args: {
where: t.arg({
type: this.builder.generator.getWhereUnique('CenterStaff'),
required: true,
}),
},
resolve: async (query, root, args, ctx, info) => {
return await this.prisma.centerStaff.delete({
...query,
where: args.where,
});
},
}),
}));
}
}

View File

@@ -1,9 +1,9 @@
// import { forwardRef, Inject, Injectable } from '@nestjs/common';
// import { Injectable } from '@nestjs/common';
// import { NestMinioService } from 'nestjs-minio';
// import { ConfigService } from '@nestjs/config';
// @Injectable()
// export class MinioService {
// constructor(
// @Inject(forwardRef(() => ConfigService))
// private configService: ConfigService,
// ) {}
// export class MinioService extends NestMinioService {
// constructor(configService: ConfigService) {
// super(configService);
// }
// }

View File

@@ -63,20 +63,23 @@ export class UserSchema extends PothosSchema {
});
},
}),
// userByToken: t.prismaField({
// type: this.user(),
// args: this.builder.args({
// oauthToken: t.arg.string({ required: true }),
// }),
// resolve: async (query, root, args, ctx, info) => {
// // check if the token is valid
// const { user } = await clerkClient.verifyToken
// return await this.prisma.user.findFirst({
// ...query,
// where: args.where,
// });
// },
// }),
userBySession: t.prismaField({
type: this.user(),
args: {
sessionId: t.arg({ type: 'String', required: true }),
},
resolve: async (query, root, args, ctx, info) => {
// check if the token is valid
const session = await clerkClient.sessions.getSession(args.sessionId);
console.log(session);
return await this.prisma.user.findFirst({
...query,
where: {
id: session.userId,
},
});
},
}),
}));
// Mutation section

View File

@@ -25,9 +25,6 @@ async function bootstrap() {
const document = SwaggerModule.createDocument(app, config);
SwaggerModule.setup(process.env.SWAGGER_PATH ?? 'v1', app, document);
console.log(process.env.API_PATH);
document.paths[process.env.API_PATH + '/graphql'] = {
get: {