What is GraphQL to Prisma Schema Converter?
This tool converts GraphQL Schema Definition Language (SDL) into Prisma schema definitions. It maps GraphQL types to Prisma models, handles type conversions (ID to String with @id, etc.), generates @relation annotations for object type fields, and adds @map annotations for snake_case column naming conventions.
How to Use
- Select your database provider (PostgreSQL, MySQL, SQLite, or MongoDB)
- Paste your GraphQL schema SDL with type definitions into the input area
- Click "Generate" to create the Prisma schema
- Save the output as schema.prisma and run prisma generate to create the client
Why Use This Tool?
Tips & Best Practices
- Review the generated schema and adjust field modifiers as needed
- Add @@unique constraints for fields that should be unique together
- The tool adds @default(cuid()) for ID fields - change to @default(uuid()) if preferred
- Run prisma validate to check the generated schema for errors
Frequently Asked Questions
How are GraphQL ID types handled?
GraphQL ID types are mapped to Prisma String with @id @default(cuid()) annotations. This provides auto-generated unique identifiers for your models.
How are relationships generated?
Object type fields (non-scalar types) are converted to Prisma relations with @relation annotations. Foreign key fields (e.g., authorId) are automatically added for object relations, and array fields use the [] syntax for one-to-many relationships.
What about enums and custom scalar types?
The tool handles basic enum types by keeping them as-is in the Prisma schema. Custom scalar types that are not recognized are treated as String. You may need to manually adjust these in the generated schema.
Does this support MongoDB?
Yes, you can select MongoDB as the provider. Note that MongoDB has different features (e.g., no @@map for tables), so you may need to adjust the generated schema for MongoDB-specific patterns.
Is my schema data sent to a server?
No, all processing happens entirely in your browser. Your GraphQL schema never leaves your device.