update fields

This commit is contained in:
2024-10-15 02:39:06 +07:00
parent 7cfab52e77
commit 80743b0973
5 changed files with 67 additions and 7 deletions

View File

@@ -26,7 +26,7 @@ export class UploadedFileSchema extends PothosSchema {
id: t.exposeID('id'),
userId: t.exposeID('userId'),
fileName: t.exposeString('fileName'),
type: t.exposeString('type'),
fileType: t.expose('fileType', { type: this.uploadedFileType() }),
fileUrl: t.exposeString('fileUrl'),
uploadedAt: t.expose('uploadedAt', { type: 'DateTime' }),
user: t.relation('user'),
@@ -34,6 +34,13 @@ export class UploadedFileSchema extends PothosSchema {
});
}
@PothosRef()
uploadedFileType() {
return this.builder.enumType('UploadedFileType', {
values: ['IMAGE', 'OTHER'],
});
}
@Pothos()
init(): void {
this.builder.queryFields((t) => ({
@@ -96,6 +103,10 @@ export class UploadedFileSchema extends PothosSchema {
type: 'Upload',
required: true,
}),
fileType: t.arg({
type: this.uploadedFileType(),
required: true,
}),
},
resolve: async (query, root, args, ctx, info) => {
const user = await this.prisma.user.findUnique({
@@ -122,6 +133,7 @@ export class UploadedFileSchema extends PothosSchema {
userId: user.id,
fileName: filename,
type: mimetype,
fileType: args.fileType,
fileUrl: fileUrl,
uploadedAt: new Date(),
},