Proper types with implementing ResolverInterface
and inheritance.
#1263
-
I am trying to implement @ObjectType()
class Type1 {
@Field()
field1: string;
}
@Resolver((_of) => Type1)
class Res1 implements ResolverInterface<Type1> {
@FieldResolver()
async field1(@Arg('arg1') arg1: string) {
return 'hello';
}
} And the problem is that you cant use
The same but without @ObjectType()
class Type1 {
@Field()
field1: string;
}
@Resolver((_of) => Type1)
class Res1 implements ResolverInterface<Type1> {
@FieldResolver()
async field1() {
return 'hello';
}
} Is there some way to handle it? I did not found examples in docs. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
In 90% of cases, field resolvers are making computation based on the parent object (
|
Beta Was this translation helpful? Give feedback.
In 90% of cases, field resolvers are making computation based on the parent object (
root
in the error message).So you can:
@Root() root: Type1
as the first parameterResolverInterface
ResolverInterface
type that does not check the first argument at all.