0.1.40 • Published 9 months ago

@prevalentware/prisma-cosmo v0.1.40

Weekly downloads
-
License
MIT
Repository
-
Last release
9 months ago

šŸš€ Prisma-Cosmo

A powerful tool that automatically generates SDL-first GraphQL types and resolvers from your Prisma schema.

🌟 Features

  • 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

šŸ“¦ Installation

# Using bun (recommended)
bun add prisma-cosmo

# Using npm
npm install prisma-cosmo

# Using yarn
yarn add prisma-cosmo

šŸ› ļø Usage

Basic Usage

  1. Place your Prisma schema(s) in the prisma folder:

    • For a single schema: prisma/schema.prisma
    • For multiple schemas: prisma/schema/*.prisma
  2. Run Cosmo:

bun run cosmo
  1. 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.

Schema Organization

You can organize your Prisma schema in two ways:

  1. Single Schema File:

    • Place your schema in prisma/schema.prisma
  2. Multiple Schema Files:

    • Place your schemas in prisma/schema/ directory
    • Example structure:
      prisma/
      ā”œā”€ā”€ schema/
      │   ā”œā”€ā”€ auth.prisma
      │   ā”œā”€ā”€ users.prisma
      │   └── products.prisma
      Cosmo will automatically merge these files when needed.

Ignoring Models

To exclude specific models from generation, add the /// cosmo-ignore comment above the model:

/// cosmo-ignore
model TemporaryData {
  id Int @id
  data String
}

šŸ“š Generated Structure

prisma/
└── generated/
    ā”œā”€ā”€ models/
    │   └── [model]/
    │       ā”œā”€ā”€ types.ts
    │       ā”œā”€ā”€ resolvers.ts
    │       └── dataLoaders.ts
    └── schema.graphql

šŸ”§ Configuration

No additional configuration needed! Cosmo follows Prisma's schema conventions and automatically generates appropriate GraphQL types and resolvers.

šŸ¤ Contributing

We welcome contributions! Please feel free to submit a Pull Request.

šŸ“ License

MIT

šŸ’Ŗ Support

If you find any bugs or have feature requests, please create an issue on our GitHub repository.

For direct support:

šŸ¢ About

Developed and maintained by prevalentWare

0.1.40

9 months ago

0.1.38

10 months ago

0.1.39

9 months ago

0.1.34

10 months ago

0.1.35

10 months ago

0.1.36

10 months ago

0.1.37

10 months ago

0.1.33

1 year ago

0.1.32

1 year ago

0.1.30

1 year ago

0.1.31

1 year ago

0.1.27

1 year ago

0.1.28

1 year ago

0.1.29

1 year ago

0.1.24

1 year ago

0.1.25

1 year ago

0.1.26

1 year ago

0.1.23

1 year ago

0.1.20

3 years ago

0.1.21

3 years ago

0.1.22

3 years ago

0.1.17

3 years ago

0.1.18

3 years ago

0.1.19

3 years ago

0.1.16

3 years ago

0.1.15

3 years ago

0.1.11

3 years ago

0.1.12

3 years ago

0.1.13

3 years ago

0.1.14

3 years ago

0.1.10

4 years ago

0.1.8

4 years ago

0.1.9

4 years ago

0.1.0

4 years ago

0.1.2

4 years ago

0.1.1

4 years ago

0.1.7

4 years ago

0.1.4

4 years ago

0.1.3

4 years ago

0.1.6

4 years ago

0.1.5

4 years ago

0.0.15

4 years ago

0.0.14

4 years ago

0.0.13

4 years ago

0.0.12

4 years ago

0.0.11

4 years ago

0.0.10

4 years ago

0.0.9

4 years ago

0.0.8

4 years ago

0.0.7

4 years ago

0.0.6

4 years ago

0.0.5

4 years ago

0.0.4

4 years ago

0.0.3

4 years ago

0.0.2

4 years ago

0.0.1

4 years ago