I'm working on an application which uses GraphQL and NestJS. In resolvers, I get args argument via @Args() parameter decorator. Most of the times, args is an object of the form { where: <GraphQL Filter>, input: <Input Object> }.
In every resolver class method, after retrieving the args, I'm applying my custom function (from another service class) to format the args.where object.
I wanted to reduce this repetition and implement a custom pipe to use as @Args(FormatPipe) args but this doesn't seem to work: NestJS docs mention that custom pipes only work with @Query, @Param(), @Body() and custom decorators but @Args() is not included.
Update: Pipe is working fine now, but I can't adjust the argument type when the pipe is applied. @Args(Pipe) args: AdjustedType throws error in reflectFromMetadata internal function.
I tried making one abstract class AbstractPipe which is called by Pipe passing metadata options. So that I wanted to apply the pipe as @Args(new Pipe({ metatype: OriginalArgsType }) args: AdjustedArgsType which would enable the developer to enjoy the correct types while NestJS enjoying the expected original type. But this didn't resolve that error. I'm not sure why.