add context subscription
This commit is contained in:
@@ -138,8 +138,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');
|
||||
}
|
||||
// get centerId by user id from context
|
||||
const userId = ctx.me.id;
|
||||
const userId = ctx.http.me.id;
|
||||
if (!userId) {
|
||||
throw new Error('User ID is required');
|
||||
}
|
||||
@@ -213,6 +216,9 @@ 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');
|
||||
}
|
||||
return this.prisma.$transaction(async (prisma) => {
|
||||
// validate input
|
||||
if (args.approved && !args.adminNote) {
|
||||
@@ -264,7 +270,7 @@ export class CenterMentorSchema extends PothosSchema {
|
||||
data: {
|
||||
content: args.adminNote ?? '',
|
||||
mentorId: mentor.id,
|
||||
notedByUserId: ctx.me.id,
|
||||
notedByUserId: ctx.http.me.id,
|
||||
},
|
||||
});
|
||||
// update user role
|
||||
@@ -310,7 +316,7 @@ export class CenterMentorSchema extends PothosSchema {
|
||||
adminNote: {
|
||||
create: {
|
||||
content: args.adminNote ?? '',
|
||||
notedByUserId: ctx.me.id,
|
||||
notedByUserId: ctx.http.me.id,
|
||||
updatedAt: new Date(),
|
||||
},
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user