MichalLytek / type-graphql

Create GraphQL schema and resolvers with TypeScript, using classes and decorators!
https://typegraphql.com
MIT License
8.02k stars 675 forks source link

Options for Arg and Args decorators no longer supports custom validate function #1514

Closed Oweeee closed 11 months ago

Oweeee commented 12 months ago

Describe the Bug An update to the typing of ValidateOptions (one of the arguments of the @Arg and @Args decorators) removed the options of passing a custom validation function to the validate property.

This change was merged with this commit, included in the 2.0.0-beta.2 release, but the list of breaking changes only lists this as a change to the buildSchema function, and instructs to use the validateFn option instead. I can't find any corresponding change documentation in regards to the decorators.

Was the effects this would have on said decorators intended?

To Reproduce Providing a custom function in the arguments of the @Arg and @Args decorators now produce a type error.

Example of a basic query

@Query(() => Boolean)
foo(@Args({validate: (argsValue, argsType) => {...}}) { bar, baz }: ArgsWithCustomValidation) {
    return true
}

Expected Behavior As the change is not explicitly documented, I expect the decorators to still support taking a custom validation function

Environment (please complete the following information):

MichalLytek commented 12 months ago

I see what happened. I will add a test case to confirm that. I guess it was an undocumented feature, but it should be supported.

Oweeee commented 12 months ago

Thank you for the speedy response to this, @MichalLytek! If you want, I could look into both returning support for this as well as adding the corresponding test case.

MichalLytek commented 11 months ago

@Oweeee Closing as implemented in 3914b78 🔒