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:
@@ -16,7 +16,7 @@
|
|||||||
"indentStyle": "space",
|
"indentStyle": "space",
|
||||||
"indentWidth": 2,
|
"indentWidth": 2,
|
||||||
"lineEnding": "lf",
|
"lineEnding": "lf",
|
||||||
"lineWidth": 80,
|
"lineWidth": 120,
|
||||||
"attributePosition": "auto",
|
"attributePosition": "auto",
|
||||||
"bracketSpacing": true
|
"bracketSpacing": true
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -1,10 +1,5 @@
|
|||||||
import { Inject, Injectable } from '@nestjs/common'
|
import { Inject, Injectable } from '@nestjs/common'
|
||||||
import {
|
import { Pothos, PothosRef, PothosSchema, SchemaBuilderToken } from '@smatch-corp/nestjs-pothos'
|
||||||
Pothos,
|
|
||||||
PothosRef,
|
|
||||||
PothosSchema,
|
|
||||||
SchemaBuilderToken,
|
|
||||||
} from '@smatch-corp/nestjs-pothos'
|
|
||||||
import { Builder } from '../Graphql/graphql.builder'
|
import { Builder } from '../Graphql/graphql.builder'
|
||||||
import { PrismaService } from '../Prisma/prisma.service'
|
import { PrismaService } from '../Prisma/prisma.service'
|
||||||
import { MinioService } from 'src/Minio/minio.service'
|
import { MinioService } from 'src/Minio/minio.service'
|
||||||
@@ -98,8 +93,7 @@ export class WorkshopSchema extends PothosSchema {
|
|||||||
workshops: t.prismaField({
|
workshops: t.prismaField({
|
||||||
type: [this.workshop()],
|
type: [this.workshop()],
|
||||||
args: this.builder.generator.findManyArgs('Workshop'),
|
args: this.builder.generator.findManyArgs('Workshop'),
|
||||||
description:
|
description: 'Retrieve a list of workshops with optional filtering, ordering, and pagination.',
|
||||||
'Retrieve a list of workshops with optional filtering, ordering, and pagination.',
|
|
||||||
resolve: async (query, _root, args, _ctx, _info) => {
|
resolve: async (query, _root, args, _ctx, _info) => {
|
||||||
return await this.prisma.workshop.findMany({
|
return await this.prisma.workshop.findMany({
|
||||||
...query,
|
...query,
|
||||||
@@ -123,7 +117,10 @@ export class WorkshopSchema extends PothosSchema {
|
|||||||
}),
|
}),
|
||||||
},
|
},
|
||||||
description: 'Create a new workshop.',
|
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({
|
return await this.prisma.workshop.create({
|
||||||
...query,
|
...query,
|
||||||
data: args.input,
|
data: args.input,
|
||||||
|
|||||||
Reference in New Issue
Block a user