Skip to content

FieldResolver inheritance #1031

Answered by MichalLytek
jpbarbosa asked this question in Q&A
Discussion options

You must be logged in to vote
export const createRecordResolver = <T extends Record>(
  objectTypeCls: ClassType<T>
) => {
  @Resolver(() => objectTypeCls, { isAbstract: true })
  abstract class BaseResolver {
    @FieldResolver()
    async user(@Root() record: T) {
      console.log(record);
    }
  }

  return BaseResolver;
};

When you understand the basic TypeGraphQL classes and () => metadata, then you will learn how to create any type of types inheritance.

Replies: 1 comment 1 reply

Comment options

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

Answer selected by jpbarbosa
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