-
Notifications
You must be signed in to change notification settings - Fork 421
Closed
Description
Bug Report
Current behavior
When i create a DTO for my mutation having a FileUpload field and binding the ValidationPipe, i get the error:
TypeError: Promise resolver undefined is not a function
at new Promise (<anonymous>)
at TransformOperationExecutor.transform (/Users/victorassis/Workspace/barreiroclub/nestjs-graphql-upload-error/node_modules/class-transformer/TransformOperationExecutor.js:117:32)
at _loop_1 (/Users/victorassis/Workspace/barreiroclub/nestjs-graphql-upload-error/node_modules/class-transformer/TransformOperationExecutor.js:235:45)
at TransformOperationExecutor.transform (/Users/victorassis/Workspace/barreiroclub/nestjs-graphql-upload-error/node_modules/class-transformer/TransformOperationExecutor.js:260:17)
at ClassTransformer.plainToClass (/Users/victorassis/Workspace/barreiroclub/nestjs-graphql-upload-error/node_modules/class-transformer/ClassTransformer.js:17:25)
at Object.plainToClass (/Users/victorassis/Workspace/barreiroclub/nestjs-graphql-upload-error/node_modules/class-transformer/index.js:20:29)
at ValidationPipe.transform (/Users/victorassis/Workspace/barreiroclub/nestjs-graphql-upload-error/node_modules/@nestjs/common/pipes/validation.pipe.js:41:39)
at /Users/victorassis/Workspace/barreiroclub/nestjs-graphql-upload-error/node_modules/@nestjs/core/pipes/pipes-consumer.js:16:33
at processTicksAndRejections (internal/process/task_queues.js:97:5)
Input Code
I created the repo https://github.com/VictorAssis/nestjs-graphql-upload-error with a resolver called CategoriesResolver that demonstrates the upload working witthout ValidationPipe and with ValidationPipe but without DTO and the case when occurs error (with ValidationPipe and with DTO).
// CategoriesResolver
@Mutation(returns => String)
@UsePipes(ValidationPipe)
async createWithDtoWithValidation (@Args() newCategory: NewCategoryInput) {
const file = await newCategory.file
return `It does not work ${file.filename}`
}
// NewCategoryInput
@ArgsType()
export class NewCategoryInput {
@Field()
@IsString()
@MinLength(3, { message: 'Name too short.' })
name: string;
@Field(type => GraphQLUpload)
file: FileUpload
}
Expected behavior
Receive the Promise in my resolver as when I'm not using ValidationPipe.
Possible Solution
I tried to set transform: false
in the ValidationPipe options but was ignored.
Another attempt was to set @Exclude
for the property in the DTO, but the property did not come in the resolver method.
Environment
Nest version: 7.0.0
Metadata
Metadata
Assignees
Labels
No labels