Recently I've been getting pretty deep into Prisma. Prisma is a DB as a service replacing traditional ORMs with an auto-generated client library.  This is a WIP article which is meant to review Prisma.io versus other options and act as a brain-dump as I use it and learn more.

The reason I chose Prisma was because it was tightly coupled with the tutorials I was going through on How to GraphQL. The site is run by the Prisma team and so after finishing a handful of their tutorial tracks, I felt pretty comfortable moving forward with my Prisma & GraphQL setup.

With just a few commands in the terminal, you can basically spin up a API Middleware layer tied to a deployed API and Postgres Database on the Prisma cloud. Unlike other DB as a Service platforms like Hasura, Prisma still requires you to run your own middleware API.

In my case my GraphQL server is a NodeJS server using graphql-yoga  implementation.

One of the things I really like about Prisma is that managing your DB Tables is all done through a datamodel.prisma file which looks like this:

If I need to add a new column, say Hobbies for instance. I simple add a new type and setup relationships with other types. Then I run prisma deploy and it will validate my schema, and then send it to the deployed prisma server where it will make the necessary Postgres changes to my DB tables. It will setup relationship tables between types, add new columns, etc. I don't ever directly manage my databases.

After making changes to the database, it generates a new client library in src/generated/prisma-client. This is the ORM which I use to interact with the database. I can do this through commands like

const bob = await prisma
  .users({ email: "bob@prisma.io" }

I don't write any SQL for these interactions. The ORM has been able to handle all of my requests thus far for things like filtering and sorting.

It's got it's issues though

I've run into some issues with Prisma that are worth talking about.

Support

For one their support is less than ideal. They have a slack channel and a forum, but it's pretty standard for your questions to go unanswered. You see a ton of people asking questions and very few providing answers.

Complex DB Schema's might not be supported

If you have a more complex DB Schema, there's a chance Prisma can't support it. I'm currently trying to implement a new DB schema and I've been trying to get answers at whether Prisma can support what I'm trying to do. I have yet to receive a straight answer.

Cost

Prisma cannot run on the Heroku free tier or on Zeit because of its image size and resource consumption. I spun up the Prisma back-end using their AWS Cloud Formation template, and with zero traffic, I was being billed $90/month. In comparison Hasura can service a few thousand complex GraphQL queries per second well within a 100MB of RAM which means you can build a side-project that scales to a thousand concurrent users at 5$ a month running both Postgres and Hasura.

Alternate Software

Prisma isn't the only software out there to offer what they do. Here are some alternatives: