FieldResolver inheritance #1031
-
Following the resolver inheritance recipes and further help from @MichalLytek (#1029) I was able to run queries and mutations from an abstract class. Now I facing an error with FieldResolver: export const createRecordResolver = <T extends Record>(
objectTypeCls: ClassType<T>
) => {
@Resolver({ isAbstract: true })
abstract class BaseResolver {
@FieldResolver()
async user(@Root() record: T) {
console.log(record);
}
}
return BaseResolver;
}; Error: No provided object type in '@Resolver' decorator for class 'BaseResolver!' The same situation was previously mentioned in this issue: #102 It would be great to have some FieldResolver examples in the documentation. Thank you again. |
Beta Was this translation helpful? Give feedback.
Answered by
MichalLytek
Sep 16, 2021
Replies: 1 comment 1 reply
-
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 |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
jpbarbosa
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
When you understand the basic TypeGraphQL classes and
() =>
metadata, then you will learn how to create any type of types inheritance.