fix upload
This commit is contained in:
@@ -43,18 +43,8 @@ export class CenterSchema extends PothosSchema {
|
|||||||
description: t.exposeString('description', {
|
description: t.exposeString('description', {
|
||||||
description: 'The description of the center.',
|
description: 'The description of the center.',
|
||||||
}),
|
}),
|
||||||
logoUrl: t.string({
|
logoUrl: t.exposeString('logoUrl', {
|
||||||
description: 'The URL of the center logo.',
|
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', {
|
logoFile: t.relation('logoFile', {
|
||||||
description: 'The file associated with the center logo.',
|
description: 'The file associated with the center logo.',
|
||||||
|
|||||||
@@ -50,18 +50,8 @@ export class ServiceSchema extends PothosSchema {
|
|||||||
imageFileId: t.exposeID('imageFileId', {
|
imageFileId: t.exposeID('imageFileId', {
|
||||||
description: 'The ID of the image file for the service.',
|
description: 'The ID of the image file for the service.',
|
||||||
}),
|
}),
|
||||||
imageFileUrl: t.string({
|
imageFileUrl: t.exposeString('imageFileUrl', {
|
||||||
description: 'The URL of the image file for the service.',
|
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', {
|
createdAt: t.expose('createdAt', {
|
||||||
type: 'DateTime',
|
type: 'DateTime',
|
||||||
|
|||||||
@@ -42,18 +42,8 @@ export class UploadedFileSchema extends PothosSchema {
|
|||||||
nullable: false,
|
nullable: false,
|
||||||
description: 'The type of the file.',
|
description: 'The type of the file.',
|
||||||
}),
|
}),
|
||||||
fileUrl: t.string({
|
fileUrl: t.exposeString('fileUrl', {
|
||||||
description: 'The URL of the file.',
|
description: 'The URL of the file.',
|
||||||
resolve: async (file, args, ctx) => {
|
|
||||||
const fileUrl = await this.minioService.getFileUrl(
|
|
||||||
file.fileName,
|
|
||||||
'files',
|
|
||||||
);
|
|
||||||
if (!fileUrl) {
|
|
||||||
return '';
|
|
||||||
}
|
|
||||||
return fileUrl;
|
|
||||||
},
|
|
||||||
}),
|
}),
|
||||||
uploadedAt: t.expose('uploadedAt', {
|
uploadedAt: t.expose('uploadedAt', {
|
||||||
type: 'DateTime',
|
type: 'DateTime',
|
||||||
|
|||||||
@@ -46,18 +46,8 @@ export class WorkshopSchema extends PothosSchema {
|
|||||||
imageFileId: t.exposeID('imageFileId', {
|
imageFileId: t.exposeID('imageFileId', {
|
||||||
description: 'The ID of the image file for the workshop.',
|
description: 'The ID of the image file for the workshop.',
|
||||||
}),
|
}),
|
||||||
imageFileUrl: t.string({
|
imageFileUrl: t.exposeString('imageFileUrl', {
|
||||||
description: 'The URL of the image file for the workshop.',
|
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', {
|
date: t.expose('date', {
|
||||||
type: 'DateTime',
|
type: 'DateTime',
|
||||||
|
|||||||
Reference in New Issue
Block a user