chore: combine context
This commit is contained in:
@@ -58,10 +58,7 @@ 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, ctx) => {
|
||||
if (ctx.isSubscription) {
|
||||
throw new Error('Workshops cannot be retrieved in subscription context')
|
||||
}
|
||||
resolve: async (query, _root, args, _ctx) => {
|
||||
return await this.prisma.workshopSubscription.findMany({
|
||||
...query,
|
||||
skip: args.skip ?? undefined,
|
||||
@@ -75,16 +72,13 @@ export class WorkshopSubscriptionSchema extends PothosSchema {
|
||||
type: [this.workshopSubscription()],
|
||||
description: 'Retrieve a list of workshops that the current user is subscribed to.',
|
||||
resolve: async (query, _root, _args, ctx, _info) => {
|
||||
if (ctx.isSubscription) {
|
||||
throw new Error('Workshops cannot be retrieved in subscription context')
|
||||
}
|
||||
if (!ctx.http.me) {
|
||||
if (!ctx.me) {
|
||||
throw new Error('User is not authenticated')
|
||||
}
|
||||
return await this.prisma.workshopSubscription.findMany({
|
||||
...query,
|
||||
where: {
|
||||
userId: ctx.http.me.id,
|
||||
userId: ctx.me.id,
|
||||
},
|
||||
})
|
||||
},
|
||||
@@ -100,10 +94,7 @@ export class WorkshopSubscriptionSchema extends PothosSchema {
|
||||
}),
|
||||
},
|
||||
resolve: async (_query, _root, args, ctx) => {
|
||||
if (ctx.isSubscription) {
|
||||
throw new Error('Not allowed in subscription')
|
||||
}
|
||||
const userId = ctx.http.me?.id
|
||||
const userId = ctx.me?.id
|
||||
// retrieve the workshop
|
||||
const workshop = await this.prisma.workshop.findUnique({
|
||||
where: { id: args.workshopId },
|
||||
|
||||
Reference in New Issue
Block a user