Skip to content

[Question] Prisma + Interfaces? #1369

Answered by hayes
erandagan asked this question in Q&A
Discussion options

You must be logged in to vote

The typescript type/interface describes the data returned by your resolvers and what is available on the parent object.

If you add isFollowed to the interface, all the types that implement Media need to have that property (which they don't)

If the parent object (eg. the movie row from the db) doesn't have the isFollowed property, you can't "expose" it because it doesn't exist.

You can use normal field methods without a resolver to define the field on the interface. This implements it with a default resolver that just throws an error.

When you add an isFollowed field on types that implement Media you are overwriting that default resolver, so it won't throw for those types.

Just removing th…

Replies: 3 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by hayes
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants
Converted from issue

This discussion was converted from issue #1359 on January 04, 2025 08:00.