graphql-code-generator icon indicating copy to clipboard operation
graphql-code-generator copied to clipboard

A way to exculde Maybe<> type from a generated TS schema

Open pid0r-3blan opened this issue 2 years ago • 5 comments

Is your feature request related to a problem? Please describe.

For frontend we set maybeValue: T | undefined in config and in this case it's not clear why we need Maybe type at all, because TypeScript guides usually suggest to prefer optional types over T | undefined.

For example user?: User will work as good as user?: Maybe<User> and of course better than if we specify avoidOptionals: true. With avoidOptionals and typescript's strictNullChecks turned on it'll throw an error if I don't specify user for user: Maybe<User> (which is right from TS perspective, but not right from actual usage cases – if some value is optional, I prefer to not specify it at all then to write { someValue: undefined }).

Describe the solution you'd like

Add to config a way to exclude Maybe type at all from all the optional value types.

Describe alternatives you've considered

No response

Is your feature request related to a problem? Please describe.

No response

pid0r-3blan avatar Jan 26 '23 14:01 pid0r-3blan