Nice work @turadg! And apologies for not making this forum article more findable/available/(insert another lame excuse here) : Prisma Beta.2 and RWJS: Limited Generator Support for Relations (with workarounds)
I’d be willing to try with a head nod from maintainers.
^^ I want to fan this flame but need to provide a little background first! Back in April, we didn’t know yet where Prisma syntax and features for relations would settle. So we didn’t want to offer full generator support until that happened. (Or at least then have the discussion about the appropriate scope of generator support.) Originally the workaround from my forum topic above was going to live in api/lib/db.js
, but this also felt like we’d potentially run into backward compatibility issues. (aside: then we talked about creating our own wrapper for the Prisma Client, which we would then import in db.js, which could possibly allow some magic but at least make it clear where the magic was coming from. So this is why we kept the db.js)
So where we are today is that relations are a confusing, sticky point for a lot of people. But there are a lot of types of relations that Prisma can handle (here’s the list).
To discuss:
- Does Redwood Scaffold support generators and, if so, which types?
- If not all types, how will Redwood handle the DX when a developer runs a Scaffold generators? (Currently it’s kind of a worst case false positive – generator ran successfully, CRUD is busted)
Given all that, what are your initial thoughts/reactions? I’m game to keep exploring, just say the word.