update subscribe to workshop
This commit is contained in:
@@ -38,6 +38,9 @@ export class WorkshopSubscriptionSchema extends PothosSchema {
|
||||
description:
|
||||
'The date and time the workshop subscription was created.',
|
||||
}),
|
||||
notified: t.exposeBoolean('notified', {
|
||||
description: 'Whether the user has been notified about the workshop.',
|
||||
}),
|
||||
}),
|
||||
})
|
||||
}
|
||||
@@ -73,5 +76,27 @@ export class WorkshopSubscriptionSchema extends PothosSchema {
|
||||
},
|
||||
}),
|
||||
}))
|
||||
this.builder.mutationFields((t) => ({
|
||||
subscribeToWorkshop: t.prismaField({
|
||||
type: this.workshopSubscription(),
|
||||
args: {
|
||||
workshopId: t.arg.string({
|
||||
description: 'The ID of the workshop to subscribe to.',
|
||||
required: true,
|
||||
}),
|
||||
},
|
||||
resolve: async (_query, _root, args, ctx) => {
|
||||
if (ctx.isSubscription) throw new Error('Not allowed in subscription')
|
||||
const userId = ctx.http.me?.id
|
||||
if (!userId) throw new Error('User not authenticated')
|
||||
return await this.prisma.workshopSubscription.create({
|
||||
data: {
|
||||
userId,
|
||||
workshopId: args.workshopId,
|
||||
},
|
||||
})
|
||||
},
|
||||
}),
|
||||
}))
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user