# prisma-generate-schema

> Transform prisma datamodel SDL into graphql-js SDL

Latest version **1.34.12** (published 2021-01-12) · Apache-2.0 license · 5.2K weekly downloads

## Install

```sh
npm install prisma-generate-schema
pnpm add prisma-generate-schema
yarn add prisma-generate-schema
bun add prisma-generate-schema
```

## Health

**Score 35/100 (D)** — status: abandoned.

Positive: has types; no vulnerabilities; high quality score.

Warnings: no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.34.12 |
| Published | 2021-01-12 |
| First published | 2018-09-05 |
| Weekly downloads | 5.2K |
| License | Apache-2.0 |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 4 |
| Unpacked size | 323.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Emanuel Jöbstl |
| Maintainers | timsuchanek |

## Links

- npm: https://www.npmjs.com/package/prisma-generate-schema
- npm.io page: https://npm.io/package/prisma-generate-schema

## Dependencies (4)

- [graphql](https://npm.io/package/graphql.md) ^14.3.0
- [popsicle](https://npm.io/package/popsicle.md) 10
- [pluralize](https://npm.io/package/pluralize.md) ^7.0.0
- [prisma-datamodel](https://npm.io/package/prisma-datamodel.md) 1.34.12

## Recent versions

- 1.34.12 (latest) — 2021-01-12
- 1.36.0-alpha.11 (alpha) — 2019-06-14
- 1.35.0-beta (beta) — 2019-05-29
- 1.22.0-alpha.0.1 (test) — 2018-11-09
- 1.34.11 — 2021-01-12
- 1.34.10 — 2019-10-14
- 1.34.8 — 2019-08-29
- 1.34.7 — 2019-08-26
- 1.34.6 — 2019-08-20
- 1.34.5 — 2019-08-09
- 1.34.3 — 2019-07-24
- 1.30.5 — 2019-07-23
- 1.34.2 — 2019-07-19
- 1.34.1 — 2019-07-07
- 1.36.0-alpha.10 — 2019-06-13
- … 459 more at https://npm.io/package/prisma-generate-schema/versions

## README

# prisma-generate-schema

This module is capable of generating a prisma [OpenCRUD](https://www.opencrud.org/) schema for a given datamodel, given in SDL.

## Developing

Development uses typescript, npm, yarn and jest.

```
yarn
npm run test
```

## Usage

Basic Usage:

```typescript
import { generateCRUDSchemaString } from 'prisma-generate-schema'

const openCRUDSchema = generateCRUDSchemaString(modelInSDL)
```

## Project Structure

This section is intended for maintainers.

First, a datamodel is parsed using the `Parser` class from `prisma-datamodel`,  Then, an OpenCRUD schema is created using the [`SchemaGenerator`](src/generator/default/schemaGenerator.ts).

The schema generator utilizes several other generators to generate the `mutation`, `query` and `subscription` objects and all corresponding types.
A [`Generator`](src/generator/generator.ts) is usually responsible for a single type only but will access other generators to recursively build the schema. All generators which return object types implement lazy evaluation and caching of generated types via their base class. The generators can be configured using dependency injection, if needed, to switch out the implementation for certain types in the schema.

All default generators, i.e. generators for a **relational model**, one for each type that can occur in an OpenCRUD schema, can ge found in the [`DefaultGenerators`](src/generator/default/index.ts) class.

All special document generators, i.e. generators for a **document model**, can ge found in the [`DocumentGenerators`](src/generator/document/index.ts) class.

---
_Source: https://npm.io/package/prisma-generate-schema · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
