Is it possible to link two types with an ID that i...
# prisma-whats-new
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
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?
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
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?
Should look something like
type Person @model{donations: [Donation!]!} @relation(name: "DonationPerson")
type Donation @model{person: Person! @relation(name: "DonationPerson")}
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
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
Yes, I'm trying to find some documentation on how to define a sub-resolver
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
resolver correctly, you should be able to query
{Donation(id: "123"){person: {email}}
and it just works
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?
Alas, I'm not as familiar with the Prisma backend 😕 @Fitch any pointers?
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 ..
Ok, thanks