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,
});
},
}),
}));
}
}