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

Resolver return type requires unnecessary properties #2665

Closed
mastilver opened this issue Oct 2, 2019 · 2 comments

Comments

@mastilver
Copy link

commented Oct 2, 2019

Describe the bug

Hi

I'm not sure if it's even possible
A resolver type requires me to add property to an object when it's being handle by another resolver
For example I have

  • a user resolver that only send firstName and lastName
  • a fullName resolver on the User object

the user resolver type still requires me to return fullName

To Reproduce

Expected behavior

The type for the user resolver not to include fullName
The only way I can see this issue resolved is by looking at the resolvers object by I might be missing something and it's already possible?

Thank you

@ardatan

This comment has been minimized.

Copy link
Collaborator

commented Oct 2, 2019

So, your entity type has firstName and lastName. You should define a type like below,,

export interface UserEntity {
   firstName: string;
   lastName: string;
}

then use mappers field inside codegen.yml;

mappers:
    User: ./user-entity#UserEntity

User type belongs to GraphQL Schema but UserEntity is something else you returned from db or other data source.

@ardatan ardatan closed this Oct 2, 2019
@ardatan ardatan added the question label Oct 2, 2019
@mastilver

This comment has been minimized.

Copy link
Author

commented Oct 2, 2019

Thank you for the quick answer! 👍

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