How do I query self-relations?
I guess my schema must be wrong. But I think I've followed the Prisma docs carefully. I currently have the schema beneath. I am trying to query a user by its id, and include the
following
and followedBy
. But it aint working. I am just receiving the 500 status (from the catch block).
The schema
The query
4 Replies
wait, isnt following and followed by just a list of users?
I dont think that you need a new model for the follows
That was my initial thought too. And I hope you're right. But then I don't know why the heck they would do it that way too in the docs? Not quite familiar with SQL relations. https://www.prisma.io/docs/concepts/components/prisma-schema/relations/self-relations
But I still can't include the followers or the following with your schema
in the dosc it doesnt tell you to create a new model
ohh
try it and see if it works
Worked now with this schema
Maybe my client didnt get regenerated properly before when changing the schema. I guess I cold just go with this implicitly. As of right now, I don't think I'll need any other fields for the following/follower stuff.