feat: add completedOrders field to Order schema and enhance workshop subscription error handling

- Introduced a new `completedOrders` field in the Order schema to retrieve a list of completed orders for the authenticated user, filtering by order status and schedule dates.
- Enhanced error handling in the WorkshopSubscription schema to prevent retrieval in subscription context, improving the robustness of the API.
- Updated imports in order.schema.ts to include additional status types from Prisma for better functionality.
This commit is contained in:
2024-12-05 21:31:38 +07:00
parent 0d973a6544
commit 1b7329bb44
2 changed files with 47 additions and 2 deletions

View File

@@ -58,7 +58,8 @@ export class WorkshopSubscriptionSchema extends PothosSchema {
type: [this.workshopSubscription()],
args: this.builder.generator.findManyArgs('WorkshopSubscription'),
description: 'Retrieve a list of workshop subscriptions with optional filtering, ordering, and pagination.',
resolve: async (query, _root, args) => {
resolve: async (query, _root, args, ctx) => {
if (ctx.isSubscription) throw new Error('Workshops cannot be retrieved in subscription context')
return await this.prisma.workshopSubscription.findMany({
...query,
skip: args.skip ?? undefined,