Skip to content

Conversation

@AmanVarshney01
Copy link
Member

@AmanVarshney01 AmanVarshney01 commented Jan 14, 2026

Summary by CodeRabbit

  • Documentation
    • Added new section on middleware chaining with query extensions, explaining execution order and providing practical examples including Logging and Audit implementation patterns.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 14, 2026

Walkthrough

This PR adds documentation explaining how to chain Prisma Client query extensions together with examples of Logging and Audit middleware implementations. The section clarifies FIFO execution order and provides code samples demonstrating timing measurement and auditing of write operations.

Changes

Cohort / File(s) Summary
Documentation: Client Extensions
content/200-orm/200-prisma-client/300-client-extensions/index.mdx
Added new section "Middleware chaining with query extensions" describing extension composition, FIFO precedence, and two concrete examples (Logging and Audit) with implementation code

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~5 minutes

Possibly related PRs

  • DC-5043 Middleware removed from docs #7233: Removes middleware documentation examples while this PR adds extension-based logging and audit examples as the recommended replacement pattern for composing middleware behavior.
🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: adding a documentation section about middleware chaining to the client extensions documentation.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


🧹 Recent nitpick comments
content/200-orm/200-prisma-client/300-client-extensions/index.mdx (2)

169-171: Consider using a consistent import path throughout the documentation.

Line 170 imports from './generated/prisma', while other examples in this same file (lines 76, 234) import from '@prisma/client'. While both are valid—./generated/prisma being the newer default output path—mixing styles on the same documentation page can confuse readers.

For consistency within this file, consider aligning with the existing pattern:

📝 Suggested change
-import { PrismaClient } from './generated/prisma'
+import { PrismaClient } from '@prisma/client'

Alternatively, if the intent is to showcase the newer generated path, it may be worth updating the other examples in this file for uniformity (though that's a larger change).


186-198: Good example—consider noting that other write operations exist.

The audit extension cleanly demonstrates the concept. One minor observation: the check at line 191 catches 'create', 'update', and 'delete', but Prisma also has 'createMany', 'updateMany', 'deleteMany', and 'upsert' as write operations.

For a documentation example, this simplification is reasonable. However, you might add a brief comment or note so readers know this isn't exhaustive:

📝 Optional enhancement
       async $allOperations({ model, operation, args, query }) {
+          // Note: For production, also consider 'createMany', 'updateMany', 'deleteMany', 'upsert'
           if (['create', 'update', 'delete'].includes(operation)) {

This is purely a nice-to-have for completeness—the example works well as-is for teaching the pattern.


📜 Recent review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 38c1be1 and 4d26c2e.

📒 Files selected for processing (1)
  • content/200-orm/200-prisma-client/300-client-extensions/index.mdx
🧰 Additional context used
🧠 Learnings (1)
📚 Learning: 2026-01-06T22:06:57.725Z
Learnt from: newclarityex
Repo: prisma/docs PR: 7425
File: content/200-orm/050-overview/500-databases/400-mysql.mdx:80-80
Timestamp: 2026-01-06T22:06:57.725Z
Learning: In Prisma docs, when showing examples of instantiating driver adapters with connection strings from environment variables, use the template literal pattern `const connectionString = `${process.env.DATABASE_URL}`` for consistency across all database adapter examples (PostgreSQL, MySQL/MariaDB, etc.).

Applied to files:

  • content/200-orm/200-prisma-client/300-client-extensions/index.mdx
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: Check internal links
  • GitHub Check: Cloudflare Pages
🔇 Additional comments (1)
content/200-orm/200-prisma-client/300-client-extensions/index.mdx (1)

165-199: Nice addition explaining middleware chaining!

This section effectively demonstrates how query extensions compose in FIFO order. The two examples (timing measurement and audit logging) are practical, complementary use cases that help readers understand the pattern quickly.

The code is correct—the logging extension properly awaits the inner query before calculating duration, and the audit extension correctly passes through to query(args) in all cases.

✏️ Tip: You can disable this entire section by setting review_details to false in your review settings.


Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions
Copy link
Contributor

Dangerous URL check

No absolute URLs to prisma.io/docs found.
No local URLs found.

@github-actions
Copy link
Contributor

Redirect check

This PR probably requires the following redirects to be added to static/_redirects:

  • This PR does not change any pages in a way that would require a redirect.

@github-actions
Copy link
Contributor

@cloudflare-workers-and-pages
Copy link

Deploying docs with  Cloudflare Pages  Cloudflare Pages

Latest commit: 4d26c2e
Status: ✅  Deploy successful!
Preview URL: https://40efc05b.docs-51g.pages.dev
Branch Preview URL: https://middilware-chaining.docs-51g.pages.dev

View logs

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.

3 participants