Prisma 2.0 – Type-safe and auto-generated database client
Prisma&#x27;s architecture seems novel and ... a little strange to me. It works by running a Rust engine as a subprocess and then communicating with the engine from JS land over a non-spec compliant GraphQL API. The engine holds the actual databae connection pool and does all the SQL generation and data marshalling. See <a href="https:&#x2F;&#x2F;www.prisma.io&#x2F;docs&#x2F;reference&#x2F;tools-and-interfaces&#x2F;prisma-client&#x2F;query-engine&#x2F;" rel="nofollow">https:&#x2F;&#x2F;www.prisma.io&#x2F;docs&#x2F;reference&#x2F;tools-and-interfaces&#x2F;pr...</a> for more info on this arrangement.<p>It has some weird ramifications though:<p>- when they go to implement a new feature (like recently added JSON column support) they have to implement it on both sides which can cause bugs like this: <a href="https:&#x2F;&#x2F;github.com&#x2F;prisma&#x2F;prisma&#x2F;issues&#x2F;2432" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;prisma&#x2F;prisma&#x2F;issues&#x2F;2432</a><p>- they&#x27;re a little limited to the semantics of GraphQL based RPC, which namely excludes any stateful stuff like arbitrary START TRANSACTION; blocks that might or might not commit. See <a href="https:&#x2F;&#x2F;github.com&#x2F;prisma&#x2F;prisma-client-js&#x2F;issues&#x2F;349" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;prisma&#x2F;prisma-client-js&#x2F;issues&#x2F;349</a> for more info on that<p>- they don&#x27;t run everywhere JavaScript runs like the browser or Cloudflare Workers (unless there&#x27;s something fancy that compiles the engine to WASM I&#x27;m not aware of)<p>I wonder if their intention is to re-use the engine between different JS processes for caching &#x2F; sharding or something like that, or to add Prisma clients in other languages. Why create the indirection?<p>I do like Prisma&#x27;s type safety compared to the pure TypeScript alternatives like TypeORM and MikroORM -- it&#x27;s really good at typing the results of specific queries and preventing you from accessing stuff that wasn&#x27;t explicitly loaded. The style of the query language is the cleanest I&#x27;ve seen out of the three as well IMO.<p>Edit: I think node modules can install arbitrary binaries to some serverless JS runtimes, not sure specifically about Cloudflare but I know their dev tool bundles JS using webpack, which would exclude other binaries from node_modules.