Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why use Prisma in a backend environment?

Tags:

graphql

prisma

After learning about GraphQL and using it in a few projects, I finally wanted to give Prisma a go. It promises to eliminate the need for a database and it generates a GraphQL client and a working database from the GraphQL Schema. So far so good.

But my question is: A GraphQL client to me really only seems useful for a client (prevent overfetching, speed up pages, React integrations, ...). Prisma however does not eliminate the need for business logic, and so one would end up using the generated client library in Node.js, just to reexport a lot of the functionality in yet another GraphQL server to the actual client.

Why should I prefer Prisma over a custom database solution? Is there a thought behind having to re-expose a lot of endpoints to the actual client?

like image 529
NikxDa Avatar asked Dec 01 '22 14:12

NikxDa


1 Answers

I work at Prisma and would love to clarify this!

Here's a quick note upfront: Prisma is not a "GraphQL-as-a-Service" tool (in the way that Graphcool, AppSync or Hasura are). The Prisma client is not a "GraphQL client", it's a database client (similar to an ORM). So, the reason for not using the Prisma client on the frontend is the same as for why you wouldn't use an ORM or connect to the DB directly from the frontend.

It promises to eliminate the need for a database and it generates a GraphQL client and a working database from the GraphQL Schema. So far so good.

I'm really curious to hear where exactly you got this perception from! We're well aware that we need to improve our communication about the value that Prisma provides and how it works. What you've formulated there is an extremely common misconception about Prisma that we want to prevent in the future. We're actually planning to publish a blog post about this exact topic next week, hopefully that will clarify a lot.

To pick up the concrete points:

  • Prisma doesn't eliminate the need for a database. Similar to an ORM, the Prisma client used to simplify database access. It also makes database migrations easier with a declarative data modelling and migrations approach (we're actually currently working on large improvements to our migration system, you can find the RFC for it here).
  • Another major benefit of Prisma is the upcoming Prisma Admin, a data management tool. The first preview for that will be available next week.
like image 195
nburk Avatar answered Jan 25 '23 12:01

nburk