dotansimha / dotansimha/graphql-code-generator

avoidOptionals should not make non-mapped resolvers required

Open
#3,278 5 comments 11 reactions 1 assignee Claimed by @kamilkisiela View on GitHub
core kind/enhancement plugins
Dominant language
TypeScript
Stars
11.3k
Forks
1.4k
Avg merge
1d 1h
Merged PRs (30d)
23

Description

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

I've enabled `avoidOptionals` because I want to ensure all of my field resolvers are written.

However, `avoidOptionals` means I have to specify resolvers for every single type in the GQL schema, even "do nothing" / pure-DTO result types.

**Describe the solution you'd like**

`avoidOptionals` IMO should not require resolvers (in the `Resolvers` type) for any type that does not have a mapper defined.

If there is not a mapper, that means the ParentType exactly matches the GQL type, i.e. the fields must already line up 1-to-1, so I should not be required to provide a resolver for that (even with `avoidOptionals` enabled).

**Describe alternatives you've considered**

Disabling `avoidOptionals` so that I don't need to provide resolvers for non-mapped types, but this means the resolvers of my mapped types then lose their type safety.

I'd be willing to attempt a PR if this sounds okay.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.