Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generated ResolversTypes invalid when using mappers for interface types #1670

Closed
koenpunt opened this Issue Apr 8, 2019 · 1 comment

Comments

Projects
None yet
2 participants
@koenpunt
Copy link
Contributor

koenpunt commented Apr 8, 2019

When specifying mappers for implementations of an interface where one of the fields is referring to another mapped type, the generated resolver type consists of a union with fields of the graphql type, instead of those from the typescript interface.

I've created a (trivial) sample project where the invalid generated types are visible:

https://github.com/koenpunt/gql-codegen-interfaces

When you look at resolver-types.ts#L108, you'll see that the omit of the pages property is invalid (because that property doesn't exist on the typescript type).

Also when you looks at resolvers.ts#L43, you'll see that the __resolveType function doesn't accept the type that was specified in the mapper.

What a solution could be (and what I currently have applied by using patch-package), is to not apply the omit logic when the interface type has a mapper specified.
But since interfaces are being considered a special case here, it might have implications I'm not aware of.

Environment:

  • OS:
  • @graphql-codegen/typescript-resolvers: 1.0.7
  • NodeJS: 10.14.1

koenpunt added a commit to koenpunt/graphql-code-generator that referenced this issue Apr 8, 2019

@koenpunt koenpunt changed the title Generated ResolversTypes invalid when using mappers Generated ResolversTypes invalid when using mappers for interface types Apr 8, 2019

@dotansimha dotansimha closed this in 0819a02 Apr 9, 2019

@dotansimha dotansimha reopened this Apr 9, 2019

@dotansimha

This comment has been minimized.

Copy link
Owner

dotansimha commented Apr 17, 2019

Fixed in 1.1.0 🚀

@dotansimha dotansimha closed this Apr 17, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.