Let’s say I have this:
type User {
id: ID! @id
email: String! @unique
customer: Customer
}
I want to retrieve the customer. I’ve seen two ways to do it in the docs but none of theme are satisfying.
Solution 1
let customer = await prisma.user({ email: args.email }).customer()
Now, how can I access to the user record itself?
Solution 2
let user: User = await prisma.user({ email: args.email }).$fragment(`
fragment EnsureCustomer on User {
id
email
customer {
id
}
}
`)
While I can use user.customer
to access the data, this makes my IDE cry as the customer
property doesn’t exist in User
(I’m using typeScript).
Any thought on that ?