can't add decorator @IsUUID()
from class-validator
to my param productI
, I don't want use additional dto. How to fix it?
@UseGuards(new AuthGuard(['user', 'admin']))
@Mutation(() => ProductEntity)
async updateProduct(
@User() user,
@Args('productId', {})
//@IsUUID() Unable to resolve signature of parameter decorator when called as an expression.
productId: string,
@Args('inputs', {})
inputs: UpdateProductInputDto,
): Promise<ProductEntity> {
return this.productService.updateProduct(user.id, productId, inputs);
}
CodePudding user response:
There's no way around it. If you want to use @IsUUID()
and the ValidationPipe
, you have to use a class DTO. If you're just looking to validate the UUID
though, you could use the ParseUUIDPipe
. @Args('productId', {}, new ParseUUIDPipe({ version: 4 }))