chore: combine context
This commit is contained in:
@@ -139,11 +139,11 @@ export class CenterMentorSchema extends PothosSchema {
|
||||
},
|
||||
resolve: async (_query, _root, args, ctx) => {
|
||||
return this.prisma.$transaction(async (prisma) => {
|
||||
if (ctx.isSubscription) {
|
||||
throw new Error('Not allowed')
|
||||
if (!ctx.me) {
|
||||
throw new Error('User not found')
|
||||
}
|
||||
// get centerId by user id from context
|
||||
const userId = ctx.http.me?.id
|
||||
const userId = ctx.me.id
|
||||
if (!userId) {
|
||||
throw new Error('User ID is required')
|
||||
}
|
||||
@@ -205,8 +205,8 @@ export class CenterMentorSchema extends PothosSchema {
|
||||
adminNote: t.arg({ type: 'String', required: false }),
|
||||
},
|
||||
resolve: async (_query, _root, args, ctx, _info) => {
|
||||
if (ctx.isSubscription) {
|
||||
throw new Error('Not allowed')
|
||||
if (!ctx.me) {
|
||||
throw new Error('User not found')
|
||||
}
|
||||
return this.prisma.$transaction(async (prisma) => {
|
||||
// get mentor info
|
||||
@@ -255,7 +255,7 @@ export class CenterMentorSchema extends PothosSchema {
|
||||
data: {
|
||||
content: args.adminNote ?? '',
|
||||
mentorId: mentor.id,
|
||||
notedByUserId: ctx.http.me?.id ?? '',
|
||||
notedByUserId: ctx.me.id,
|
||||
},
|
||||
})
|
||||
// update user role
|
||||
@@ -310,7 +310,7 @@ export class CenterMentorSchema extends PothosSchema {
|
||||
adminNote: {
|
||||
create: {
|
||||
content: args.adminNote ?? '',
|
||||
notedByUserId: ctx.http.me?.id ?? '',
|
||||
notedByUserId: ctx.me.id,
|
||||
updatedAt: new Date(),
|
||||
},
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user