Skip to content
Discussion options

You must be logged in to vote

Hi @RMHonor,

You can set mappers to explicitly declare what you'd like to return in User "nodes".

For example:

// codegen.ts
const config: CodegenConfig = {
  // ... other config
  'src/types.generated.ts': {
    plugins: ['typescript', 'typescript-resolvers'],
    config: {
      mappers: {
        User: './mappers#UserMapper'
      }
    }
  }
}

And in the mappers.ts file:

export type UserMapper = {
  id: string,
  firstName: string,
  lastName: string,
}

This forces all resolvers (including __resolveReference) that return User type in the schema to return UserMapper instead.

Note that in your example of ResolverWithReference and ResolverWithoutReference, User.fullName resolver's parent…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@RMHonor
Comment options

Answer selected by RMHonor
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants