Query on Referral with self-relation


#1

I have a referral datamodel like:

type Referral {
  id: ID! @id
  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:

const referral = await prisma.referral({ where: { referee: { id: user.id } } });

But gotten the error:

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’ve also tried this which doesn’t work as I expected either:

const referral = await prisma.referral({ where: { referee: user.id } });