简体   繁体   中英

Automatically sanitize @Args in type-graphql

Is it possible to automatically sanitize the args?

...
  @Mutation(returns => Ok)
  async signup(@Args() args: args.GetSignupArgs ) {
    sanitize(args);
    const { name, email, password } = args;
    const checkUser = await this.userRepository.findOne({ email })
...

You should be able to do this by injecting a global middleware. See: https://github.com/19majkel94/type-graphql/blob/master/docs/middlewares.md

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM