NestJs with GraphQL and Prisma
Prisma is an open-source ORM for Node.js and TypeScript. It is used as an alternative to writing plain SQL, or using another database access tool such as SQL query builders (like knex.js) or ORMs (like TypeORM and Sequelize). Prisma currently supports PostgreSQL, MySQL, SQL Server, SQLite, MongoDB and CockroachDB
While Prisma can be used with plain JavaScript, it embraces TypeScript and provides a level to type-safety that goes beyond the guarantees other ORMs in the TypeScript ecosystem. You can find an in-depth comparison of the type-safety guarantees of Prisma and TypeORM
Prisma is a next-generation ORM that can be used to query a database in NestJS apps
It embraces TypeScript to avoid runtime errors and improve productivity. The type-safety it provides goes far beyond the guarantees of traditional ORMs like TypeORM or Sequelize
Prisma integrates smoothly with the modular architecture of NestJS, no matter if you’re building REST or GraphQL APIs. It is typically used within your NestJS services to fulfill the data needs of the controllers
Why Prisma and NestJs?
Embracing TypeScript
Prisma is the first ORM that provides full type-safety, even when querying partial models and relations.
Smooth integration
Prisma fits perfectly into the modular architecture of NestJS and provides a powerful database access layer.
Type-safe database client
Prisma Client ensures fully type-safe database queries with benefits like autocompletion – even in JavaScript.
Intuitive data modeling
Prisma’s declarative modeling language is simple and lets you intuitively describe your database schema.
Easy database migrations
Generate predictible and customizable SQL migrations from the declarative Prisma schema.
Designed for building APIs
Prisma Client reduces boilerplates by providing queries for common API features (e.g. pagination, filters, …).