Is it possible to add @InterfaceType() to generated models? #332
Unanswered
dickfickling
asked this question in
Q&A
Replies: 1 comment 2 replies
-
In the docs you will find a way to add more fields to generated models. |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I have a User model in my schema that I extend with an AuthorizedUser class to represent the logged-in user and expose private info.
Schema:
Extended User type
Authorized User Resolver:
This all seems to work, and I can query users and authorized users as expected. However, on the front end, I can't use a single fragment to query either model.
I get the error
Fragment "userProfile" cannot be spread here as objects of type "AuthorizedUser" can never be of type "User".
So naturally, I'd like to add an annotation to my AuthorizedUser class that indicates that it implements
User
, a la@ObjectType({ implements: User })
. But I also need to specify thatUser
is anInterfaceType()
, which I can't seem to do, because it's generated automatically by typegraphql-prisma.Two questions:
User
is anInterfaceType
?Beta Was this translation helpful? Give feedback.
All reactions