refactor and update get url logic

This commit is contained in:
2024-10-17 17:02:03 +07:00
parent 4721077370
commit f9967ac5bd
22 changed files with 45 additions and 40 deletions

View File

@@ -39,7 +39,19 @@ export class UploadedFileSchema extends PothosSchema {
nullable: false,
description: 'The type of the file.',
}),
fileUrl: t.exposeString('fileUrl'),
fileUrl: t.string({
description: 'The URL of the file.',
resolve: async (file, args, ctx) => {
const fileUrl = await this.minioService.getFileUrl(
file.fileName,
'files',
);
if (!fileUrl) {
throw new Error('Cannot retrieve file url');
}
return fileUrl;
},
}),
uploadedAt: t.expose('uploadedAt', {
type: 'DateTime',
nullable: true,