MichalLytek / MichalLytek/type-graphql

Transforming input fields

Open
#340 9 comments 6 reactions 0 assignees View on GitHub
Community :family_man_girl: Enhancement :new:
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

Open the contributing 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.