Clément
03/12/2019, 5:02 PMtype Human {
id: ID! @unique
brain: Brain
}
type Brain {
id: ID! @unique
human: Human!
}
This is an optional one-to-one relation, how should I check the existence of this relation from Human perspective ?
I did:
const brain = await prisma.human({ id }).brain()
if (!brain) { ... }
But the typing is not correct, brain
is of type Brain
, and not Brain | undefined
Am I doing something wrong ? Thanks đlawjolla
03/12/2019, 5:07 PMgraphqlgen
, try regenerating the types, especially if you recently changed the schema to allow humans to not have brains. đ€ŁClĂ©ment
03/12/2019, 5:09 PMprisma generate
to generate TypeScript clientlawjolla
03/12/2019, 5:10 PMClément
03/12/2019, 5:10 PMClément
03/12/2019, 5:11 PM.brain()
returns a BrainPromise
, extends the Promise<Brain>
typelawjolla
03/12/2019, 5:11 PMbrain: Brain | undefined
?Clément
03/12/2019, 5:11 PMClément
03/12/2019, 5:12 PMlawjolla
03/12/2019, 5:12 PMClément
03/12/2019, 5:13 PMexport interface HumanPromise extends Promise<Human>, Fragmentable {
id: () => Promise<ID_Output>;
brain: <T = BrainPromise>() => T;
}
^ return type of .human(...)
Clément
03/12/2019, 5:13 PMexport interface Human {
id: ID_Output;
}
lawjolla
03/12/2019, 5:18 PMlawjolla
03/12/2019, 5:20 PMany
and leave a note to revisit it in two weeks. Normally by then the bug works itself outClément
03/12/2019, 5:44 PMClément
03/12/2019, 5:45 PMClément
03/12/2019, 5:45 PMschickling
03/12/2019, 6:26 PMdivyendu
03/12/2019, 7:43 PMClément
03/13/2019, 7:15 AMdivyendu
03/18/2019, 9:52 AMClément
03/21/2019, 9:42 AM