Skip to content

Conversation

@jlecordier
Copy link
Contributor

@jlecordier jlecordier commented Jun 18, 2025

The description of the example did not match the example

Summary by CodeRabbit

  • Documentation
    • Clarifies applying client extensions by creating a separate extended client instance rather than modifying the base client.
    • Updates examples to show calling extended methods on the extended instance for clearer usage.
    • Notes that the original client remains unchanged to avoid confusion when mixing extended and non-extended calls.
    • Minor formatting improvements for readability.

ankur-arch
ankur-arch previously approved these changes Jul 7, 2025
@aidankmcalister
Copy link
Member

aidankmcalister commented Aug 3, 2025

Hello. If you can resolve these conflicts, I would be happy to review the changes.

@ankur-arch
Copy link
Contributor

@jlecordier thanks for raising this. Would you be able to resolve the merge conflicts? If not we will close this PR and resolve a fix from our side.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Sep 3, 2025

Walkthrough

Replaces an inline extension-on-construction example with a two-step pattern: instantiate PrismaClient, call prisma.$extends(findOrCreate) to create xprisma, and invoke xprisma.user.findOrCreate(). Minor spacing and inline-code formatting tweaks; base client remains unmodified.

Changes

Cohort / File(s) Summary
Docs: Prisma Client shared extensions
content/200-orm/200-prisma-client/300-client-extensions/140-shared-extensions/index.mdx
Replaced inline extension usage with: const prisma = new PrismaClient(), const xprisma = prisma.$extends(findOrCreate), and await xprisma.user.findOrCreate(). Removed direct import usage change, adjusted spacing and inline code formatting, and clarified base client is unchanged.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  actor Dev as Developer
  participant PrismaClient as PrismaClient
  participant xprisma as Extended Client

  Note over Dev,PrismaClient: Previous flow — extension applied at construction
  Dev->>PrismaClient: new PrismaClient({ extensions: [findOrCreate] })
  PrismaClient-->>Dev: prisma
  Dev->>PrismaClient: prisma.user.findOrCreate()

  rect rgba(220,255,220,0.25)
  Note over Dev,xprisma: New flow — separate extended client via $extends
  Dev->>PrismaClient: const prisma = new PrismaClient()
  Dev->>xprisma: const xprisma = prisma.$extends(findOrCreate)
  xprisma-->>Dev: xprisma
  Dev->>xprisma: xprisma.user.findOrCreate()
  end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

✨ Finishing Touches
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR/Issue comments)

Type @coderabbitai help to get the list of available commands.

Other keywords and placeholders

  • Add @coderabbitai ignore or @coderabbit ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@jlecordier
Copy link
Contributor Author

wtf happened lol, I guess I should have let you do it

@jlecordier jlecordier reopened this Sep 3, 2025
ankur-arch
ankur-arch previously approved these changes Sep 3, 2025
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (1)
content/200-orm/200-prisma-client/300-client-extensions/140-shared-extensions/index.mdx (1)

35-36: Optional: hint that await requires an async context.

A tiny comment helps readers avoid “await is only valid in async functions” errors when trying the snippet.

Apply this diff:

 const xprisma = prisma.$extends(findOrCreate)
-const user = await xprisma.user.findOrCreate()
+// inside an async function or top-level await environment
+const user = await xprisma.user.findOrCreate()
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 6e0363f and e531238.

📒 Files selected for processing (1)
  • content/200-orm/200-prisma-client/300-client-extensions/140-shared-extensions/index.mdx (1 hunks)
⏰ 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: runner / linkspector
  • GitHub Check: runner / linkspector
🔇 Additional comments (2)
content/200-orm/200-prisma-client/300-client-extensions/140-shared-extensions/index.mdx (2)

33-36: Good correction: use an extended client instance (immutability of $extends).

Switching to const xprisma = prisma.$extends(findOrCreate) and invoking xprisma.user.findOrCreate() correctly reflects that $extends returns a new client and does not mutate the original instance.


38-38: Clarification reads well.

The note correctly explains why xprisma.user.findOrCreate works while prisma.user.findOrCreate does not. Nice.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between e531238 and d6bb9b0.

📒 Files selected for processing (1)
  • content/200-orm/200-prisma-client/300-client-extensions/140-shared-extensions/index.mdx (1 hunks)
⏰ 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: runner / linkspector
🔇 Additional comments (1)
content/200-orm/200-prisma-client/300-client-extensions/140-shared-extensions/index.mdx (1)

38-38: Nice clarification about using the extended client (xprisma).

This makes the distinction from the base prisma clear.

@ankur-arch ankur-arch merged commit 5d67bd8 into prisma:main Sep 10, 2025
7 checks passed
@jlecordier jlecordier deleted the patch-4 branch September 15, 2025 18:07
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