A powerful tool that automatically generates SDL-first GraphQL types and resolvers from your Prisma schema.
- Generates GraphQL SDL types from Prisma models
- Creates basic CRUD resolvers automatically
- Supports both single and multiple Prisma schema files
- Generates TypeScript types for better type safety
- Creates DataLoaders for optimal query performance
- AWS AppSync compatible out of the box
# Using bun (recommended)
bun add prisma-cosmo
# Using npm
npm install prisma-cosmo
# Using yarn
yarn add prisma-cosmo
-
Place your Prisma schema(s) in the
prisma
folder:- For a single schema:
prisma/schema.prisma
- For multiple schemas:
prisma/schema/*.prisma
- For a single schema:
-
Run Cosmo:
bun run cosmo
- Cosmo will generate:
- GraphQL SDL types
- Basic CRUD resolvers
- TypeScript types
- DataLoaders for performance optimization
The generated code will be in the prisma/generated
directory.
You can organize your Prisma schema in two ways:
-
Single Schema File:
- Place your schema in
prisma/schema.prisma
- Place your schema in
-
Multiple Schema Files:
- Place your schemas in
prisma/schema/
directory - Example structure:
Cosmo will automatically merge these files when needed.
prisma/ ├── schema/ │ ├── auth.prisma │ ├── users.prisma │ └── products.prisma
- Place your schemas in
To exclude specific models from generation, add the /// cosmo-ignore
comment above the model:
/// cosmo-ignore
model TemporaryData {
id Int @id
data String
}
prisma/
└── generated/
├── models/
│ └── [model]/
│ ├── types.ts
│ ├── resolvers.ts
│ └── dataLoaders.ts
└── schema.graphql
No additional configuration needed! Cosmo follows Prisma's schema conventions and automatically generates appropriate GraphQL types and resolvers.
We welcome contributions! Please feel free to submit a Pull Request.
MIT
If you find any bugs or have feature requests, please create an issue on our GitHub repository.
For direct support:
- Email: [email protected]
- GitHub Issues: Create an issue
Developed and maintained by prevalentWare