What is the difference between Prisma client and Prisma bindings?


The Prisma client and Prisma bindings both provide ways to interact with the Prisma server that sits on top of your database and therefore allow you to read and write data in your database. It is generally recommended to use the Prisma client. Prisma bindings can be used for advanced use cases when building GraphQL servers.

Prisma bindings

Prisma bindings have one clear use case, they're used for implementing GraphQL resolvers based on schema delegation. This means the info object that's received by your GraphQL resolvers is passed down to the Prisma API using Prisma bindings. You can learn more about building GraphQL server with Prisma bindings here.

Prisma bindings are installed into your application using the prisma-binding package from NPM. Its API mirrors the Prisma GraphQL API.

Prisma client

The Prisma client is used as a replacement for traditional ORMs and enables you to read and write data in your database. A few of its core advantages compared to Prisma bindings are:

  • Auto-generated based on datamodel
  • Full type-safety
  • Simpler and more intuitive API (e.g. the fluent API for relations)
  • Fleixble use cases
  • Available in various programming languages

The Prisma client is auto-generated using the prisma1 generate command of the Prisma CLI. The Prisma CLI reads the information from your prisma.yml and generates the according Prisma client.

For example, consider this configuration of the generate property in your prisma.yml:

  - generator: javascript-client
    output: ./generated/js
  - generator: typescript-client
    output: ./generated/ts
  - generator: go-client
    output: ./generated/go

Running prisma1 generate with this configuration generates three versions of the Prisma client, one in JavaScript, one in TypeScript and one in Go. Note that you typically only generate the Prisma client in one language.

If you've implemented GraphQL servers using Prisma bindings before, implementing resolvers for the relations in your GraphQL schema can be a bit difficult at first. See this tutorial to learn more about implemeting relations with the Prisma client.