Skip to content

feat: port generator to Effect v4 and Prisma 7#24

Open
timzolleis wants to merge 2 commits into
m9tdev:mainfrom
timzolleis:feat/effect-v4
Open

feat: port generator to Effect v4 and Prisma 7#24
timzolleis wants to merge 2 commits into
m9tdev:mainfrom
timzolleis:feat/effect-v4

Conversation

@timzolleis

@timzolleis timzolleis commented Jun 15, 2026

Copy link
Copy Markdown

Why?

Effect v4 is in beta now (and becoming more popular!) - on the discord, people start working with it and its being recommended more and more. Since we use prisma (and this repo) pretty heavily, and want to get started on the v4 migration, having effect v4 support would mean a lot to us

Disclaimer from my side: I opened the PR to main, but I think while effect v4 is in beta, it would make more sense to maintain a separate v4 branch - but thats up to you :)

Summary

Ports the generated PrismaService to Effect v4 (effect@4.0.0-beta.x) and bumps Prisma to 7.8.0. The emitted code now uses the v4 service and runtime APIs: Context.Service in place of Context.Tag, an explicit layer in place of the auto-generated .Default, and Effect.context + Effect.runPromiseExitWith inside $transaction (the Runtime<R> API it relied on was removed in v4). The only consumer-facing change is PrismaService.Default becoming PrismaService.layer.

Changes

  • Migrate the service tags from Context.Tag to Context.Service (type params first, id passed to the returned constructor)
  • Replace Service(..., { effect }) with Context.Service(..., { make }) and add an explicit static readonly layer = Layer.effect(this, this.make)
  • Rewrite $transaction to capture the context with Effect.context and run it with Effect.runPromiseExitWith, since Runtime<R> and its runners no longer exist in v4
  • Migrate the test runner to v4 (ChildProcess / ChildProcessSpawner, NodeServices, and FileSystem from the effect barrel)
  • Upgrade effect, @effect/vitest, and @effect/platform-node to 4.0.0-beta.83, and prisma / @prisma/* to ^7.8.0
  • Update the README for .layer and add a v4 beta compatibility note

Testing

All existing integration tests pass (12 total), including transaction commit, rollback, nested transactions, and custom-error preservation, which exercise the new Effect.context / runPromiseExitWith bridge. The generated effect.ts also typechecks against effect@4.0.0-beta.83. Effect v4 is still in beta, so its APIs may shift between releases.

Thanks for the great library, especially the transaction API is pretty cool!

timzolleis and others added 2 commits June 15, 2026 15:17
- migrate context services: Context.Tag → Context.Service with inverted type params
- remove Runtime<R>; use Effect.context<R>() + Effect.runPromiseExitWith(services)
- add explicit static layer = Layer.effect(this, this.make) (no auto .Default in v4)
- update test runner: Command → ChildProcess/ChildProcessSpawner, FileSystem from effect barrel
- upgrade dependencies: effect@4.0.0-beta.83, @effect/vitest@4.0.0-beta.83, @effect/platform-node@4.0.0-beta.83, prisma@^7.8.0
- update docs: .Default → .layer, add v4 beta compatibility note
- all 12 tests pass including transaction commit/rollback and error preservation
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant