diff --git a/src/Schedule/schedule.schema.ts b/src/Schedule/schedule.schema.ts index 76991d6..f1c64a4 100644 --- a/src/Schedule/schedule.schema.ts +++ b/src/Schedule/schedule.schema.ts @@ -311,6 +311,29 @@ export class ScheduleSchema extends PothosSchema { }, }), + scheduleDates: t.prismaField({ + type: [this.scheduleDate()], + description: 'Retrieve a list of schedule dates.', + args: this.builder.generator.findManyArgs('ScheduleDate'), + resolve: async (query, _root, args, ctx, _info) => { + if (ctx.isSubscription) { + throw new Error('Cannot retrieve schedule dates in subscription') + } + if (!ctx.http?.me?.id) { + throw new Error('User not found') + } + return await this.prisma.scheduleDate.findMany({ + ...query, + skip: args.skip ?? undefined, + take: args.take ?? undefined, + orderBy: args.orderBy ?? undefined, + where: { + AND: [{ participantIds: { has: ctx.http.me.id } }, ...(args.filter ? [args.filter] : [])], + }, + }) + }, + }), + centerPreviewSchedule: t.field({ type: this.previewSchedule(), description: 'Preview a schedule for center mentor.',