fix: prisma client not found error - #22
Conversation
|
|
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
There was a problem hiding this comment.
Summary of Changes
Hello @mudiageo, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!
This pull request addresses a specific issue where projects not configured to use Prisma were failing due to an unexpected dependency on Prisma types. The core change involves refactoring the location of database-related type definitions, including those for Prisma, into a dedicated types file. This ensures that the type system correctly handles dependencies, preventing errors in environments where Prisma is not present and improving the overall modularity of the codebase.
Highlights
- Fix Prisma Client Not Found Error: Projects not utilizing Prisma were encountering a 'Prisma client not found' error due to internal type imports. This PR resolves the issue by isolating Prisma-related type definitions.
- Type Definition Refactoring: The
PrismaClienttypes and other database configuration types have been relocated fromsrc/lib/database.tsto a new dedicated type file atsrc/lib/types/database.ts. - Improved Module Separation: This change enhances module separation by ensuring that projects not dependent on Prisma do not inadvertently pull in Prisma-related dependencies through type imports, preventing runtime errors.
Using Gemini Code Assist
The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.
Invoking Gemini
You can request assistance from Gemini at any point in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.
| Feature | Command | Description |
|---|---|---|
| Code Review | /gemini review |
Performs a code review for the current pull request in its current state. |
| Pull Request Summary | /gemini summary |
Provides a summary of the current pull request in its current state. |
| Comment | @gemini-code-assist | Responds in comments when explicitly tagged, both in issue comments and review comments. |
| Help | /gemini help |
Displays a list of available commands. |
Customization
To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.
Limitations & Feedback
Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.
You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.
Footnotes
-
Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution. ↩
PR Reviewer Guide 🔍Here are some key observations to aid the review process:
|
There was a problem hiding this comment.
Code Review
This pull request correctly moves database-related types to a separate file to resolve an issue with the Prisma client. However, this refactoring has introduced a couple of issues. A type dependency (Adapter) was not moved along with the code that uses it, which will cause a build failure. Additionally, other types used for casting in database.ts are now out of scope and need to be imported. I've also pointed out that some database configuration types (MongoDBConfig, SupabaseConfig) were missing altogether and this is a good opportunity to add them for completeness and to fix related type errors.
| | DrizzleConfig | ||
| | CustomAdapterConfig; | ||
|
|
||
| import type { DatabaseConfig } from './types/database' |
There was a problem hiding this comment.
The types DrizzleConfig, MongoDBConfig, and SupabaseConfig are used for type casting within createDatabaseAdapter but are no longer defined or imported in this file. They need to be imported from ./types/database to prevent build errors. Note that this is also dependent on MongoDBConfig and SupabaseConfig being defined in that file, which I've commented on separately.
| import type { DatabaseConfig } from './types/database' | |
| import type { DatabaseConfig, DrizzleConfig, MongoDBConfig, SupabaseConfig } from './types/database' |
| } | ||
|
|
||
| // Union type for all database configurations | ||
| export type DatabaseConfig = | ||
| | PrismaConfig | ||
| | DrizzleConfig | ||
| | CustomAdapterConfig; No newline at end of file |
There was a problem hiding this comment.
The types MongoDBConfig and SupabaseConfig are used in src/lib/database.ts but are not defined. They should be defined here and included in the DatabaseConfig union type. This will fix type errors in database.ts.
}
export interface MongoDBConfig extends BaseDatabaseConfig {
type: 'mongodb';
client: any;
database: string;
}
export interface SupabaseConfig extends BaseDatabaseConfig {
type: 'supabase';
client: any;
serviceRole?: any;
}
// Union type for all database configurations
export type DatabaseConfig =
| PrismaConfig
| DrizzleConfig
| CustomAdapterConfig
| MongoDBConfig
| SupabaseConfig;
PR Code Suggestions ✨Explore these optional code suggestions:
|
||||||||||||||
There was a problem hiding this comment.
Pull Request Overview
This PR fixes a Prisma client import error that was affecting projects not using Prisma by isolating Prisma-related type dependencies from the main database module.
- Moved all database type definitions from
src/lib/database.tsto a dedicated types file - Replaced direct Prisma import with type-only import in the types directory
- Updated import paths to reference the new types location
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| src/lib/types/database.ts | New file containing all database type definitions with isolated Prisma type import |
| src/lib/types/config.ts | Updated DatabaseConfig import path to reference the new types directory |
| src/lib/database.ts | Removed type definitions and Prisma import, keeping only the adapter utility function |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
| @@ -0,0 +1,41 @@ | |||
| import type { PrismaClient } from '@prisma/client' | |||
There was a problem hiding this comment.
The type-only import from '@prisma/client' will still cause a runtime error if the package is not installed. Consider using a conditional type import or making this dependency optional to truly isolate Prisma from non-Prisma projects.
| // Specific database provider configurations | ||
| export interface CustomAdapterConfig extends BaseDatabaseConfig { | ||
| type: 'custom'; | ||
| adapter: Adapter; |
There was a problem hiding this comment.
The Adapter type is not imported in this file. This will cause a TypeScript error since Adapter is used but not defined or imported.
User description
Projects not using prisma are getting prisma client not found error. We're using prisma internally to get types for
PrismaClient. This PR moves the types from the src/lib/database.js to the src/lib/types directoryPR Type
Bug fix
Description
Move database types to separate types directory
Fix Prisma client import error for non-Prisma projects
Isolate Prisma dependency from main database module
Diagram Walkthrough
File Walkthrough
database.ts
Remove database types and Prisma importsrc/lib/database.ts
DatabaseConfigfrom types directoryconfig.ts
Update DatabaseConfig import pathsrc/lib/types/config.ts
DatabaseConfigtypedatabase.ts
Add database types with Prisma importsrc/lib/types/database.ts