Question about a self relation query, I have a ref...
# orm-help
c
Question about a self relation query, I have a referral datamodel like:
Copy code
type Referral {
  referrer: User! @relation(name: "UserReferrals")
  referee: User! @relation(name: "UserReferee")
}
When I try to get the referral by the referee with prisma client, I’m doing this:
Copy code
const referral = await prisma.referral({ where: { referee: { id: user.id } } });
But gotten the error:
Copy code
Variable '$where' expected value of type 'ReferralWhereUniqueInput!' but got: {\"where\":{\"referee\":{\"id\":\"cjyu929lr00c7086128xdf46n\"}}}. Reason: 'where' Field 'where' is not defined in the input type 'ReferralWhereUniqueInput'. (line 1, column 8):\nquery ($where: ReferralWhereUniqueInput!)
I might be getting somewhere with:
Copy code
const referral = await prisma.referrals().referee({ where: { id: user.id } });
but getting the error
Could not find argument where for type User
h
when it was complaining about
ReferralWhereUniqueInput
it's because referee isnt a unique field. usually you use id or tag a field as unique to index by. Look at the generated schema docs to see what the input should look like.
k
@Hasen could you share a link to "generated schema docs"? I'm having the same problem with user - friends