Update VSCode settings for line width and refactor imports in workshop.schema.ts; enhance workshop creation resolver with authentication checks

This commit is contained in:
2024-11-26 00:56:01 +07:00
parent dc2397d73e
commit c4e302387f
2 changed files with 7 additions and 10 deletions

View File

@@ -16,7 +16,7 @@
"indentStyle": "space",
"indentWidth": 2,
"lineEnding": "lf",
"lineWidth": 80,
"lineWidth": 120,
"attributePosition": "auto",
"bracketSpacing": true
},

View File

@@ -1,10 +1,5 @@
import { Inject, Injectable } from '@nestjs/common'
import {
Pothos,
PothosRef,
PothosSchema,
SchemaBuilderToken,
} from '@smatch-corp/nestjs-pothos'
import { Pothos, PothosRef, PothosSchema, SchemaBuilderToken } from '@smatch-corp/nestjs-pothos'
import { Builder } from '../Graphql/graphql.builder'
import { PrismaService } from '../Prisma/prisma.service'
import { MinioService } from 'src/Minio/minio.service'
@@ -98,8 +93,7 @@ export class WorkshopSchema extends PothosSchema {
workshops: t.prismaField({
type: [this.workshop()],
args: this.builder.generator.findManyArgs('Workshop'),
description:
'Retrieve a list of workshops with optional filtering, ordering, and pagination.',
description: 'Retrieve a list of workshops with optional filtering, ordering, and pagination.',
resolve: async (query, _root, args, _ctx, _info) => {
return await this.prisma.workshop.findMany({
...query,
@@ -123,7 +117,10 @@ export class WorkshopSchema extends PothosSchema {
}),
},
description: 'Create a new workshop.',
resolve: async (query, _root, args, _ctx, _info) => {
resolve: async (query, _root, args, ctx, _info) => {
if (ctx.isSubscription) throw new Error('Workshops cannot be created in subscription context')
if (!ctx.http.me) throw new Error('User is not authenticated to create a workshop')
return await this.prisma.workshop.create({
...query,
data: args.input,