-
-
Notifications
You must be signed in to change notification settings - Fork 676
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cannot return plain objects when using inherited ObjectTypes #160
Comments
This requirement takes place when the return type is union or your object types implements GraphQL interfaces or extends other classes. One of the super class might be implementing an GraphQL interface and unfortunately due to a limitation of current schema generation using |
Reopening as it should be fixed along with metadata storage refactoring 🔓 |
I think I am experiencing this as well. |
+1. Highly useful feature, in terms of reducing code duplication. Can't wait to extract some fields to a BaseModel ObjectType: @ObjectType()
class BaseModel {
@Field(() => String)
public id: string;
@Field(() => String)
public createdAt: string;
@Field(() => String)
public updatedAt: string;
} |
@prilutskiy |
Having the same issue with |
@19majkel94 , You the man! 👍 👍 |
Describe the bug
When I'm using inheritance between
@ObjectType
classes, I cannot return anything that is not an validinstanceof MyInheritedObjectType
. This does not happen when I use just plain, non-inherited classes.To Reproduce
There is this gist
Expected behavior
In the gist I made,
query { users }
plays just nice with the plain objects array I provided. TS also statically checks it with no problem.When calling
query { inheritedUsers }
, I expect it to have the same behavior, but it instead fails because the array does not meet the correct type.Logs
Enviorment
Additional context
This could easily be fixed by removing this verification, but I'm pretty sure that is here for a reason, and I could break somewhere else by removing it.
The text was updated successfully, but these errors were encountered: