Skip to content

fix(examples): generate each Prisma example's client into its own folder - #7806

Merged
KATT merged 1 commit into
mainfrom
cursor/prisma-client-per-example-9614
Nov 2, 2026
Merged

KATT merged 1 commit into
mainfrom
cursor/prisma-client-per-example-9614

Conversation

@KATT

@KATT KATT commented Nov 2, 2026 •

Copy link
Copy Markdown
Member

Why

  • Lint on main fails in examples/next-prisma-starter/src/pages/post/[id].tsx: Invalid type used in template literal expression on ${post.title}.
  • next-prisma-starter, next-prisma-websockets-starter and next-prisma-todomvc share one pnpm copy of @prisma/[email protected]. Each one's postinstall (prisma generate) writes its client into that shared copy, so the last one to generate wins.
  • In CI the websockets starter generates last. Its Post model has no title, so next-prisma-starter is type-checked against the wrong schema. feat(examples): next-prisma-starter on @shared/ui #7792's template-literal <title> was the first code to hit it. The merge-queue run only passed on a turbo cache hit.

What

  • Each Prisma example's generator client gets output = "../generated/prisma", so each one generates into its own generated/prisma/ folder at the example's root. The folder is gitignored.
  • The examples import PrismaClient, Prisma and Post from that folder instead of @prisma/client:
    • next-prisma-starter: src/server/prisma.ts, src/server/routers/post.ts, prisma/seed.ts;
    • next-prisma-websockets-starter: src/server/prisma.ts, src/server/routers/post.ts, prisma/seed.ts;
    • next-prisma-todomvc: src/server/prisma.ts.
  • @prisma/client stays a dependency: the generated client loads its runtime from it.
  • The folder is at the example root, not under src/, because the websockets starter's server is compiled by tsc into dist/, which doesn't copy the generated .js. ../../generated/prisma resolves the same from src/server/ and dist/server/, and oxlint src doesn't scan it.

Links

  • Next.js Pages Router: Post: the page whose <title> broke lint; it loads through the example's own client.
  • WebSockets: Chat: posts load and the live subscription works.
  • TodoMVC: All: tasks load.

Alternatives considered

  • output under src/generated/prisma. The websockets starter's production server (dist/server/*.js) would then require dist/generated/prisma, which tsc never writes.
  • Generate the three examples in a fixed order, or give each its own @prisma/client via dependenciesMeta.injected. Ordering stays fragile, and injection changes the install for every Prisma example. A per-example output is what Prisma recommends and is the same inside and outside the monorepo.
  • The prisma-client generator (ESM, TypeScript output). A bigger change to the runtime setup of three examples; not needed for this fix.

Testing

  • pnpm install --frozen-lockfile with scripts on, as in CI: all three examples generate their own generated/prisma/.
  • pnpm turbo run lint typecheck --force for all three: 0 warnings and 0 errors; tsc --noEmit passes for the websockets starter, which has no typecheck script.
  • CI's E2E sequence with --force and a separate local Postgres database per example: test-dev, build, typecheck and test-start pass for all three. The Playwright tests ran and passed, including the websockets starter's production server loading the client from dist/server/.
  • Standalone, from a clean worktree: tooling/subtree's transform keeps the output line and the postinstall generate step. Each copy installs with pnpm install --ignore-workspace, generates its client on install, and pnpm build passes.
Open in Web Open in Cursor 

View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need.

Summary by CodeRabbit

  • Chores
    • Updated the Prisma starter examples to generate and use a project-local Prisma client, including in seed scripts.
    • Generated client files are now excluded from version control in these examples. This keeps generated output out of example repositories while ensuring the starter projects use the client produced by their own Prisma schema.

@KATT
KATT requested a review from a team as a code owner November 2, 2026 12:07
@vercel

vercel Bot commented Nov 2, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
examples-todomvc Ready Ready Preview Nov 2, 2026 12:10pm UTC
next-prisma-starter Ready Ready Preview Nov 2, 2026 12:10pm UTC
next-prisma-websockets-starter Ready Ready Preview Nov 2, 2026 12:10pm UTC
4 Skipped Deployments
Project Deployment Actions Updated
tanstack-start-sse-chat Skipped Skipped Nov 2, 2026 12:10pm UTC
trpc-next-app-dir Skipped Skipped Nov 2, 2026 12:10pm UTC
trpc-v12 Skipped Skipped Nov 2, 2026 12:10pm UTC
www Skipped Skipped Nov 2, 2026 12:10pm UTC

Request Review

@coderabbitai

coderabbitai Bot commented Nov 2, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review.

Recent review info
Run configuration
Commits

Reviewing files that changed from the base of the PR and between 2458418 and 582d8f1.

Files selected for processing: 13
  • examples/next-prisma-starter/.gitignore
  • examples/next-prisma-starter/prisma/schema.prisma
  • examples/next-prisma-starter/prisma/seed.ts
  • examples/next-prisma-starter/src/server/prisma.ts
  • examples/next-prisma-starter/src/server/routers/post.ts
  • examples/next-prisma-todomvc/.gitignore
  • examples/next-prisma-todomvc/prisma/schema.prisma
  • examples/next-prisma-todomvc/src/server/prisma.ts
  • examples/next-prisma-websockets-starter/.gitignore
  • examples/next-prisma-websockets-starter/prisma/schema.prisma
  • examples/next-prisma-websockets-starter/prisma/seed.ts
  • examples/next-prisma-websockets-starter/src/server/prisma.ts
  • examples/next-prisma-websockets-starter/src/server/routers/post.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 6 remain after this review.

Walkthrough

The three Prisma example projects now generate clients under generated/prisma. Their seed scripts and server code import Prisma entities from that output, and each project ignores the generated directory.

Changes: Prisma client output

Layer / File(s) Summary
Configure and use generated Prisma clients
examples/next-prisma-starter/*, examples/next-prisma-todomvc/*, examples/next-prisma-websockets-starter/*
Each project configures Prisma client output at ../generated/prisma, updates applicable seed and server imports to use the generated client, and ignores /generated/.

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix

Suggested reviewers: juliusmarminge

Merge Risk: Minimal · up to 582d8

No actionable merge-blocking risk introduced by this PR was established.

Pre-merge checks: Passed 5
Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title clearly and concisely describes the main change: configuring each Prisma example to generate its client in a separate folder.
Docstring Coverage Passed No eligible functions found in the changed files. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentat…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Docstring Coverage

Explanation

No eligible functions found in the changed files. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 0 functions across 7 files. (6 skipped: 6 unsupported.)

Finishing Touches
Generate docstrings
  • Commit to this branch
  • Create a new PR
Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@pkg-pr-new

pkg-pr-new Bot commented Nov 2, 2026

Copy link
Copy Markdown

Open in StackBlitz

@trpc/client

npm i https://pkg.pr.new/@trpc/client@7806

@trpc/next

npm i https://pkg.pr.new/@trpc/next@7806

@trpc/openapi

npm i https://pkg.pr.new/@trpc/openapi@7806

@trpc/react-query

npm i https://pkg.pr.new/@trpc/react-query@7806

@trpc/server

npm i https://pkg.pr.new/@trpc/server@7806

@trpc/tanstack-react-query

npm i https://pkg.pr.new/@trpc/tanstack-react-query@7806

@trpc/upgrade

npm i https://pkg.pr.new/@trpc/upgrade@7806

commit: 582d8f1

@trpc-bot trpc-bot left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CI is green, including uncached lint for all three Prisma examples. LGTM.

@trpc-bot
trpc-bot added this pull request to the merge queue Nov 2, 2026
@KATT
KATT removed this pull request from the merge queue due to a manual request Nov 2, 2026
@KATT
KATT merged commit 31753a3 into main Nov 2, 2026
63 of 64 checks passed
@KATT
KATT deleted the cursor/prisma-client-per-example-9614 branch November 2, 2026 14:12
cursor Bot pushed a commit that referenced this pull request Nov 3, 2026
Brings main up to db643ba: query handles and the live docs demos
(#7759, #7817), the release commit check (#7834), the Prisma starter's
generate step (#7806), the package links test (#7809), the sponsor cards
(#7821, #7835), the PR template's AI model section (#7836) and v11.23.0.

- v11/scripts/check-release-commit.ts names v11/lerna.json and
  v11/packages/* (git gives repo-root paths) and undoes from the repo
  root; v11/package.json takes its preversion and postversion scripts
  and its effect dependencies.
- tanstack-react-query combines main's handles with #7767's feature
  flags: handles.ts reads keyPrefix through inferFeatureFlags, and
  Context.tsx passes the internal renderHandleVerbs flag through a
  variable.
- main's live demos took the ```demo fence and the demo-slot class, so
  the kitchen sink's fence is ```kitchen-sink and its slot is
  kitchen-sink-slot.
- www type-checks against v11's and v12's TanStack Query integrations,
  so v12's TanStack Query family moves to 5.105.0 with main. The
  react-spa cache test now persists through the transformer like the
  app, since 5.105.0 only falls back to initialPageParam for an
  undefined first cursor.
- www/build/package-links.test.ts reads v11/packages.
- turbo.json drops the Prisma starter's generate and lint entries.
- The PR template keeps v12's and adds main's AI model section.
- The lockfile is rebuilt from v12's, adding only the new dependencies.

Co-authored-by: Alex / KATT <[email protected]>
@github-actions

github-actions Bot commented Nov 3, 2026

Copy link
Copy Markdown
Contributor

This pull request has been locked because we are very unlikely to see comments on closed issues. If you think, this PR is still necessary, create a new one with the same branch. Thank you.

@github-actions github-actions Bot locked as resolved and limited conversation to collaborators Nov 3, 2026

This branch was successfully deployed

2 active and 2 inactive deployments
Preview – next-prisma-starter — 582d8f1c Deployed Nov 2, 2026 by vercel[bot]
Preview – examples-todomvc — 582d8f1c Deployed Nov 2, 2026 by vercel[bot]
Preview – www — 582d8f1c Deployed Nov 2, 2026 by vercel[bot]
Preview – trpc-next-app-dir — 582d8f1c Deployed Nov 2, 2026 by vercel[bot]
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants