I am having trouble with the type support?
given this schema
model Agreement {
id String @id
attendees Attendee[]
businesses BusinessPurchase[]
}
the output .sdl is right
type Agreement {
id: String!
attendees: [Attendee]!
businesses: [BusinessPurchase]!
}
but typescript complains that the service constructor is off
Property ‘attendee’ does not exist on type ‘Prisma__AgreementClient’. Did you mean ‘Attendee’?
Property ‘businessPurchase’ does not exist on type ‘Prisma__AgreementClient’. Did you mean ‘BusinessPurchase’?
export const Agreement = {
attendees: (_obj, { root }: ResolverArgs<ReturnType<typeof agreement>>) =>
db.agreement.findUnique({ where: { id: root.id } }).attendees(),
businesses: (_obj, { root }: ResolverArgs<ReturnType<typeof agreement>>) =>
db.agreement.findUnique({ where: { id: root.id } }).businesses(),
}
I have to correct it to this to get the types to be happy
export const Agreement = {
attendees: (_obj, { root }: ResolverArgs<ReturnType<typeof agreement>>) =>
db.agreement.findUnique({ where: { id: root.id } }).Attendee(),
businesses: (_obj, { root }: ResolverArgs<ReturnType<typeof agreement>>) =>
db.agreement.findUnique({ where: { id: root.id } }).BusinessPurchase(),
}
The old .35 constructor generation is nearly the same as the new .38 but doesn’t complain…
export const Agreement = {
attendees: (_obj, { root }: ResolverArgs<ReturnType<typeof Agreement>>) =>
db.agreement.findUnique({ where: { id: root.id } }).attendees(),
businesses: (_obj, { root }: ResolverArgs<ReturnType<typeof Agreement>>) =>
db.agreement.findUnique({ where: { id: root.id } }).businesses(),
};
I don’t know why the .35 was checking the type of Agreement, while the new .38 checks the type of agreement. Typing in the .38 doesn’t seem to care either way…
Am I missing something?