return properly actual file name
This commit is contained in:
@@ -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',
|
||||
|
||||
Reference in New Issue
Block a user