fix upload file type
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
import { Inject, Injectable, UploadedFiles } from '@nestjs/common';
|
import { Inject, Injectable } from '@nestjs/common';
|
||||||
import {
|
import {
|
||||||
Pothos,
|
Pothos,
|
||||||
PothosRef,
|
PothosRef,
|
||||||
@@ -8,7 +8,7 @@ import {
|
|||||||
import { Builder } from '../Graphql/graphql.builder';
|
import { Builder } from '../Graphql/graphql.builder';
|
||||||
import { PrismaService } from '../Prisma/prisma.service';
|
import { PrismaService } from '../Prisma/prisma.service';
|
||||||
import { MinioService } from 'src/Minio/minio.service';
|
import { MinioService } from 'src/Minio/minio.service';
|
||||||
|
import { UploadedFileType } from '@prisma/client';
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class UploadedFileSchema extends PothosSchema {
|
export class UploadedFileSchema extends PothosSchema {
|
||||||
constructor(
|
constructor(
|
||||||
@@ -26,7 +26,11 @@ export class UploadedFileSchema extends PothosSchema {
|
|||||||
id: t.exposeID('id'),
|
id: t.exposeID('id'),
|
||||||
userId: t.exposeID('userId'),
|
userId: t.exposeID('userId'),
|
||||||
fileName: t.exposeString('fileName'),
|
fileName: t.exposeString('fileName'),
|
||||||
fileType: t.expose('fileType', { type: this.uploadedFileType() }),
|
// expose enum
|
||||||
|
fileType: t.expose('fileType', {
|
||||||
|
type: UploadedFileType,
|
||||||
|
nullable: false,
|
||||||
|
}),
|
||||||
fileUrl: t.exposeString('fileUrl'),
|
fileUrl: t.exposeString('fileUrl'),
|
||||||
uploadedAt: t.expose('uploadedAt', { type: 'DateTime' }),
|
uploadedAt: t.expose('uploadedAt', { type: 'DateTime' }),
|
||||||
user: t.relation('user'),
|
user: t.relation('user'),
|
||||||
@@ -34,13 +38,6 @@ export class UploadedFileSchema extends PothosSchema {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@PothosRef()
|
|
||||||
uploadedFileType() {
|
|
||||||
return this.builder.enumType('UploadedFileType', {
|
|
||||||
values: ['IMAGE', 'OTHER'],
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
@Pothos()
|
@Pothos()
|
||||||
init(): void {
|
init(): void {
|
||||||
this.builder.queryFields((t) => ({
|
this.builder.queryFields((t) => ({
|
||||||
@@ -104,7 +101,7 @@ export class UploadedFileSchema extends PothosSchema {
|
|||||||
required: true,
|
required: true,
|
||||||
}),
|
}),
|
||||||
fileType: t.arg({
|
fileType: t.arg({
|
||||||
type: this.uploadedFileType(),
|
type: UploadedFileType,
|
||||||
required: true,
|
required: true,
|
||||||
}),
|
}),
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user