return properly actual file name
This commit is contained in:
@@ -7,12 +7,14 @@ import {
|
||||
} from '@smatch-corp/nestjs-pothos';
|
||||
import { Builder } from '../Graphql/graphql.builder';
|
||||
import { PrismaService } from '../Prisma/prisma.service';
|
||||
import { MinioService } from 'src/Minio/minio.service';
|
||||
|
||||
@Injectable()
|
||||
export class WorkshopSchema extends PothosSchema {
|
||||
constructor(
|
||||
@Inject(SchemaBuilderToken) private readonly builder: Builder,
|
||||
private readonly prisma: PrismaService,
|
||||
private readonly minioService: MinioService,
|
||||
) {
|
||||
super();
|
||||
}
|
||||
@@ -44,8 +46,18 @@ export class WorkshopSchema extends PothosSchema {
|
||||
imageFileId: t.exposeID('imageFileId', {
|
||||
description: 'The ID of the image file for the workshop.',
|
||||
}),
|
||||
imageFileUrl: t.exposeString('imageFileUrl', {
|
||||
imageFileUrl: t.string({
|
||||
description: 'The URL of the image file for the workshop.',
|
||||
resolve: async (workshop, args, ctx) => {
|
||||
const fileUrl = await this.minioService.getFileUrl(
|
||||
workshop.imageFileId ?? '',
|
||||
'workshops',
|
||||
);
|
||||
if (!fileUrl) {
|
||||
throw new Error('Cannot retrieve file url');
|
||||
}
|
||||
return fileUrl;
|
||||
},
|
||||
}),
|
||||
date: t.expose('date', {
|
||||
type: 'DateTime',
|
||||
|
||||
Reference in New Issue
Block a user