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,13 @@ import {
} from '@smatch-corp/nestjs-pothos';
import { Builder } from '../Graphql/graphql.builder';
import { PrismaService } from '../Prisma/prisma.service';
import { MinioService } from '../Minio/minio.service';
@Injectable()
export class ServiceSchema extends PothosSchema {
constructor(
@Inject(SchemaBuilderToken) private readonly builder: Builder,
private readonly prisma: PrismaService,
private readonly minioService: MinioService,
) {
super();
}
@@ -43,8 +44,18 @@ export class ServiceSchema extends PothosSchema {
imageFileId: t.exposeID('imageFileId', {
description: 'The ID of the image file for the service.',
}),
imageFileUrl: t.exposeString('imageFileUrl', {
imageFileUrl: t.string({
description: 'The URL of the image file for the service.',
resolve: async (service, args, ctx) => {
const fileUrl = await this.minioService.getFileUrl(
service.imageFileId ?? '',
'services',
);
if (!fileUrl) {
return '';
}
return fileUrl;
},
}),
createdAt: t.expose('createdAt', {
type: 'DateTime',