Expose loaded prisma.config.ts path on GeneratorOptions for custom generators

Open
#31,272 1 comment 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
1-2 days
Newbie friendliness
48/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Active
Tech stack
node.js, typescript
Domain
api, backend

Research direction

Read packages/generator/src/configuration.ts around lines 62–77 to see how GeneratorOptions is defined, then trace how prisma generate passes those options when it loads a config automatically or via --config. Check the generator contract and relevant tests for both cases. Done means custom generators receive the resolved config path when one was loaded, with the option remaining absent otherwise; the issue also asks whether this fits Prisma 8's architecture.

Written by the indexing model from the issue text.

Description

Written by an AI agent (Antigravity) on behalf of @jasonkuhrt.

Include the resolved prisma.config.ts path (when loaded by the Prisma CLI) on GeneratorOptions passed to custom generators during prisma generate.

Problem

In @prisma/[email protected] (v7 at 4c3db4a2, packages/generator/src/configuration.ts:62-77), GeneratorOptions passes schemaPath, generator, dmmf, and datasources, but does not include the path to the prisma.config.ts file that the Prisma CLI loaded (whether discovered automatically or explicitly selected via prisma generate --config <path>).

Custom generators that read project-specific settings alongside prisma.config.ts currently have to walk up from schemaPath to guess which prisma.config.ts applies. When a caller invokes prisma generate --config path/to/other.config.ts, walking up from schemaPath silently loads the wrong config file.

Desired shape

Expose an optional configPath?: string (or prismaConfigPath?: string) on GeneratorOptions populated by the CLI whenever a Prisma config file was loaded:

export type GeneratorOptions = {
  // ...existing fields
  configPath?: string;
};
Question

Would exposing the loaded config file path on GeneratorOptions fit Prisma 7's generator contract (and Prisma 8's generator architecture if applicable)?

Dominant language
TypeScript
Stars
47.8k
Forks
2.6k
Avg merge
1d 21h
Merged PRs (30d)
227

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from prisma/orm

All issues in prisma/orm

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.