return properly actual file name

This commit is contained in:
2024-10-17 17:25:02 +07:00
parent f9967ac5bd
commit d01fae4788
8 changed files with 61 additions and 25 deletions

View File

@@ -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',