Closed
Description
I have code that looks approximately like this.
@InterfaceType("Animal")
abstract class AnimalGQLInterface {
@Field(() => String)
abstract name: Promise<string>;
}
@ObjectType("AnimalBase", {
isAbstract: true,
implements: [AnimalGQLInterface],
})
abstract class Animal implements AnimalGQLInterface {
abstract readonly id: string;
async get name() {
return nameService.getAnimalName(this.id);
}
}
@ObjectType()
class Cat extends Animal {
/* ... */
}
@ObjectType()
class Dog extends Animal {
/* ... */
}
In other places, I accidentally wrote this:
// Incorrect: uses Animal instead of AnimalGQLInterface for decorator
@Field(() => [Animal])
pets: Animal[];
The correct code there was
@Field(() => [AnimalGQLInterface])
pets: Animal[];
Despite the fact that isAbstract: true
was set on Animal
, the resulting GraphQL schema includes AnimalBase
as a type.
What should it do?
It should throw an error that abstract type made it into the GraphQL schema.