feat: enhance GraphQL schemas and service logic
- Added support for creating relation inputs in PrismaCrudGenerator for object types. - Implemented unauthorized access checks in OrderSchema to ensure user authentication. - Added logic to prevent duplicate service registrations for users in OrderSchema. - Updated PayosService to change order status from IN_PROGRESS to WAITING_QUIZ. - Introduced a new mutation for creating multiple personal milestones in PersonalMilestoneSchema with necessary validation. - Enhanced QuizSchema to update schedule status to WAITING_INTERVIEW upon quiz attempt creation. These changes improve the robustness of the GraphQL API by adding necessary validations, enhancing user experience, and ensuring proper state management across various schemas.
This commit is contained in:
@@ -96,7 +96,46 @@ export class PersonalMilestoneSchema extends PothosSchema {
|
||||
})
|
||||
},
|
||||
}),
|
||||
|
||||
}))
|
||||
this.builder.mutationFields((t) => ({
|
||||
createManyPersonalMilestones: t.prismaField({
|
||||
type: [this.personalMilestone()],
|
||||
args: {
|
||||
scheduleId: t.arg({
|
||||
type: 'String',
|
||||
description: 'The ID of the schedule the personal milestone belongs to.',
|
||||
required: true,
|
||||
}),
|
||||
userId: t.arg({
|
||||
type: 'String',
|
||||
description: 'The ID of the user the personal milestone belongs to.',
|
||||
required: true,
|
||||
}),
|
||||
data: t.arg({
|
||||
type: [this.builder.generator.getCreateManyInput('PersonalMilestone')],
|
||||
description: 'The data for the personal milestone.',
|
||||
required: true,
|
||||
}),
|
||||
},
|
||||
description: 'Create multiple personal milestones.',
|
||||
resolve: async (_query, _root, args, ctx, _info) => {
|
||||
if (ctx.isSubscription) {
|
||||
throw new Error('Not allowed')
|
||||
}
|
||||
if (!ctx.http.me) {
|
||||
throw new Error('Cannot get your info')
|
||||
}
|
||||
const userId = ctx.http.me.id
|
||||
return await this.prisma.personalMilestone.createManyAndReturn({
|
||||
data: args.data.map((data) => ({
|
||||
...data,
|
||||
userId,
|
||||
scheduleId: args.scheduleId,
|
||||
})),
|
||||
skipDuplicates: true,
|
||||
})
|
||||
},
|
||||
}),
|
||||
}))
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user