update transaction

This commit is contained in:
2024-11-21 18:30:32 +07:00
parent cf8051b8a4
commit d56e1f9348
5 changed files with 110 additions and 128 deletions

View File

@@ -384,15 +384,16 @@ export class UserSchema extends PothosSchema {
email: t.arg({ type: 'String', required: true }),
},
resolve: async (_parent, args, ctx) => {
// check context
if (ctx.isSubscription) {
throw new Error('Not allowed')
}
// check context is admin
if (ctx.http.me?.role !== 'ADMIN') {
throw new UnauthorizedException(`Only admin can invite moderator`)
}
return this.prisma.$transaction(async (tx) => {
// check context
if (ctx.isSubscription) {
throw new Error('Not allowed')
}
// check context is admin
if (ctx.http.me?.role !== 'ADMIN') {
throw new UnauthorizedException(`Only admin can invite moderator`)
}
let user
// perform update role
try {