In Prisma, we have a concept called "Generator". A generator is an executable program, which takes the parsed Prisma schema as an input and has full freedom to output anything.

The most prominent generator is called prisma-client-js . It's the ORM Client powering the main TypeScript and JavaScript usage of Prisma from Node.js.

However, this is not the only generator. As the generator interface is open and language agnostic, everyone can plug in their own generator into their Prisma project, which can do wonderful new things.

A few examples of other generators:

Generators will always be called when you run prisma generate. However, only the generators mentioned in the schema.prisma file are being run.

This document describes, how the generator architecture looks like and how we can build our own generator.

Schema

In the schema we have a so-called generator block:

// the Prisma Client TypeScript generator
generator mygen {
  provider = "prisma-client-js"
}

// the Prisma Client docs generator
generator gen {
  provider = "node node_modules/prisma-docs-generator"
}

// the official Prisma Client Go generator
generator db {
  provider = "go run github.com/prisma/prisma-client-go"
}

The provider can either be a command like node myscript.js or a predefined alias like prisma-client-js, which is pre-shipped with the prisma CLI.

CLI

prisma generate is the key point connecting everything. Whenever a user changed something in their projects schema.prisma file, they run prisma generate to reflect the datamodel changed in the newly generated generator artifacts, like the generated TypeScript client.