add context subscription

This commit is contained in:
2024-10-29 02:21:18 +07:00
parent ba54d3466c
commit 9423a36eeb
7 changed files with 58 additions and 19 deletions

View File

@@ -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(),
},
},