MichalLytek / MichalLytek/type-graphql
Transforming input fields
- Dominant language
- TypeScript
- Stars
- 8.1k
- Forks
- 672
- PR merge metrics
- No merged PRs in 30d
Description
I find myself short of a simple way to perform reusable input field transformation.
Example:
```TypeScript
@InputType()
export class TestInput {
@Field()
name: string;
}
```
I would like to transform the name field before it reaches the resolver to do some basic transformation such as trimming and potentially throwing an error. Ideally I could use something such as `@Transform(transformFn)`.
I've tried `@UseMiddleware` but, alas, it does not work on input types.
Contributor guide
Research direction
Start by reviewing the @InputType and @Field example and the attempted @UseMiddleware approach described in the issue. Define how a proposed @Transform(transformFn) mechanism should process the name field before it reaches the resolver, including how transformation errors are reported; done means reusable input transformation works without relying on middleware for input types.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- graphql, typescript
- Domain
- api
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100