Is it possible to link two types with an ID that i...
# prisma-whats-new
j
Is it possible to link two types with an ID that is shared? I have several types that represent REST endpoints. One endpoint returns a person_id, but not the whole person
c
what do you mean by "link two types with an ID that is shared"? Like, you query a single endpoint and you can get two different types of models back?
j
I think I might have answered my own question...I am trying to resolve the person type from my resolvers when that person type is itself inside a type of Donation
c
I think you're saying you want to set up a relation between Person and Donation, then query for a Person inside of Donation?
ex: get the person associated with given donation?
j
Yes
c
Should look something like
type Person @model{donations: [Donation!]!} @relation(name: "DonationPerson")
and
type Donation @model{person: Person! @relation(name: "DonationPerson")}
j
Yea, that doesn't really work though because my data lives in a rest endpoint, so I don't store it locally
Maybe I should, though
c
I think your type definitions would be the same, you'd just need to define a resolver to get a person from a Donation node
then do
GET /your/rest/api/donations/ID/person
or whatever to resolve it
j
Yes, I'm trying to find some documentation on how to define a sub-resolver
c
What are you writing your resolvers in? I'm pretty sure most libraries dynamically make sub resolvers based on the root resolvers you have written
ie: if you've written your
Person
resolver correctly, you should be able to query
{Donation(id: "123"){person: {email}}
and it just works
j
I'm writing them in the standard prisma way
I can't seem to get that to work, not sure what I'm doing wrong
The args I'm allowed to use should show up in the schema docs on the playground, right?
c
Alas, I'm not as familiar with the Prisma backend 😕 @Fitch any pointers?
f
resolvers in utils are complex .. Ive been working on a boilerplate of our framework but it isnt ready yet .. utils loads queries and mutations .. that perform operations on prisma ..
j
Ok, thanks