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 CenterSchema extends PothosSchema {
constructor(
@Inject(SchemaBuilderToken) private readonly builder: Builder,
private readonly prisma: PrismaService,
private readonly minioService: MinioService,
) {
super();
}
@@ -34,8 +36,18 @@ export class CenterSchema extends PothosSchema {
description: t.exposeString('description', {
description: 'The description of the center.',
}),
logoUrl: t.exposeString('logoUrl', {
logoUrl: t.string({
description: 'The URL of the center logo.',
resolve: async (center, args, ctx) => {
const fileUrl = await this.minioService.getFileUrl(
center.uploadedFileId ?? '',
'centers',
);
if (!fileUrl) {
return '';
}
return fileUrl;
},
}),
logoFile: t.relation('logoFile', {
description: 'The file associated with the center logo.',