Skip to content

Schema design // How to handle polymorphism? #3668

Answered by ryands17
evandjohnston asked this question in Q&A
Discussion options

You must be logged in to vote

Hey @evandjohnston 👋

Yes currently Prisma doesn't support interfaces and unions, but as per your query

I'm trying to build a Typescript + GraphQL API server that mostly handles read requests on a strongly polymorphic dataset, as well as the usual user account management stuff.

Let's say our dataset contains Animals, with sub-types Mammals, Reptiles, Birds, etc., and sub-sub-types Canines, Felids, Primates, etc.

You are building a GraphQL API. Why not make use of Interfaces and Unions available to you in GraphQL itself instead of creating those in the database model? The best example I would suggest is something like this. This will help you add the required interfaces in the GraphQL l…

Replies: 3 comments 3 replies

Comment options

You must be logged in to vote
1 reply
@evandjohnston
Comment options

Answer selected by evandjohnston
Comment options

You must be logged in to vote
2 replies
@ryands17
Comment options

@aisensiy
Comment options

Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
5 participants