diff --git a/src/Quiz/quiz.schema.ts b/src/Quiz/quiz.schema.ts index 1c6c4c2..b391d6f 100644 --- a/src/Quiz/quiz.schema.ts +++ b/src/Quiz/quiz.schema.ts @@ -170,7 +170,13 @@ export class QuizSchema extends PothosSchema { type: this.quiz(), args: { data: t.arg({ - type: this.builder.generator.getCreateInput('Quiz', ['id', 'centerMentorId', 'createdAt', 'updatedAt']), + type: this.builder.generator.getCreateInput('Quiz', [ + 'id', + 'centerMentorId', + 'createdAt', + 'updatedAt', + 'service', + ]), required: true, }), }, @@ -184,12 +190,18 @@ export class QuizSchema extends PothosSchema { if (!args.data) { throw new Error('Data is required') } - + if (!args.data.service?.connect?.id) { + throw new Error('Service ID is required') + } + args.data.centerMentor = { + connect: { + mentorId: ctx.http.me.id, + }, + } return await this.prisma.quiz.create({ ...query, data: { ...args.data, - centerMentorId: ctx.http.me.id, }, }) },