# graphql_typeorm

> Automatically create TypeORM EntitySchema's, GraphQL resolvers, GraphQL Mutation, Query, and Input schemas from TypeORM annotated(directive) types.

Latest version **2.2.0** (published 2019-06-16) · ISC license · 0 weekly downloads

## Install

```sh
npm install graphql_typeorm
pnpm add graphql_typeorm
yarn add graphql_typeorm
bun add graphql_typeorm
```

Provides the command `graphql_typeorm`.

## Health

**Score 20/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.2.0 |
| Published | 2019-06-16 |
| First published | 2018-07-08 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 5 |
| Unpacked size | 51.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | JJ Taylor |
| Maintainers | jjwtay |

## Links

- npm: https://www.npmjs.com/package/graphql_typeorm
- Repository: https://github.com/jjwtay/graphGenTypeorm
- Homepage: https://github.com/jjwtay/graphGenTypeorm#readme
- Issues: https://github.com/jjwtay/graphGenTypeorm/issues
- npm.io page: https://npm.io/package/graphql_typeorm

## Dependencies (5)

- [ramda](https://npm.io/package/ramda.md) ^0.26.1
- [graphql](https://npm.io/package/graphql.md) ^14.3.1
- [prettier](https://npm.io/package/prettier.md) ^1.18.2
- [graphql-tag](https://npm.io/package/graphql-tag.md) ^2.10.1
- [graphschematojson](https://npm.io/package/graphschematojson.md) ^2.2.2

## Recent versions

- 2.2.0 (latest) — 2019-06-16
- 2.1.0 — 2019-06-11
- 2.0.4 — 2019-06-09
- 2.0.3 — 2019-06-09
- 2.0.2 — 2019-06-09
- 2.0.1 — 2019-06-09
- 2.0.0 — 2019-06-09
- 1.1.0 — 2018-07-10
- 1.0.4 — 2018-07-08
- 1.0.3 — 2018-07-08
- 1.0.2 — 2018-07-08
- 1.0.1 — 2018-07-08
- 1.0.0 — 2018-07-08

## README

# graphGenTypeORM
Automatically create TypeORM EntitySchema's, GraphQL resolvers, GraphQL Mutation, Query, and Input schemas from TypeORM annotated(directive) types.

# Install
    npm i graphql_typeorm

# Example Schemas decorated.

    type Author @Entity {
        id: Int! @PrimaryGeneratedColumn
        name: String! @Column
        rating: Float @Column(type: "float")
        books: [Book] @Relationship(type: "one-to-many", target: "Book")
    }

    type Book @Entity {
        id: Int! @Column(type: "int", primary: true, generated: true)
        title: String! @Column(type: "string")
        author: [Author]! @Relationship(type: "many-to-one", target: "Author")
    }
    
# Directives
| Name                    | Options | Description |
|-------------------------|---------|-------------|
| @Entity                 | [EntitySchemaOptions](https://github.com/jjwtay/graphGenTypeorm/blob/master/schemas/entity.graphql)| Determines what GraphQL Types get converted to TypeORM EntitySchema Models.|
| @Column                 | [EntitySchemaColumnOptions](https://github.com/jjwtay/graphGenTypeorm/blob/master/schemas/column.graphql)| Determines what model fields are stored in database.|
| @Relationship           | [EntitySchemaRelationshipOptions](https://github.com/typeorm/typeorm/blob/master/src/entity-schema/EntitySchemaRelationOptions.ts)| Determines that a relationship field should be created.|
| @PrimaryColumn | [EntitySchemaColumnOptions](https://github.com/jjwtay/graphGenTypeorm/blob/master/schemas/column.graphql)| Shortcut for Column type with primary = true |
| @PrimaryGeneratedColumn | [EntitySchemaColumnOptions](https://github.com/jjwtay/graphGenTypeorm/blob/master/schemas/column.graphql)| Shortcut for Column type with primary = true and generated = true| 
| @CreateDateColumn | [EntitySchemaColumnOptions](https://github.com/jjwtay/graphGenTypeorm/blob/master/schemas/column.graphql)| Shortcut for Column type with type = 'timestamp with time zone' and createDate = true |
| @UpdateDateColumn | [EntitySchemaColumnOptions](https://github.com/jjwtay/graphGenTypeorm/blob/master/schemas/column.graphql) | Shortcut for Column type with type = 'timestamp with time zone' and updateDate = true |

# Example usage CLI
    npx graphql_typeorm dir=./schemas outDir=./generated

# CLI Options (either file or dir must be included)
| Option | Default | Description |
|--------|---------|-------------|
| file   |         | .graphql schema file to generate from |
| dir    |         | Directory to find .graphql files to generate from |
| outDir | ./generated | Directory to write generated files to |
| format |   ts    | Output format. Valid options = ts/js |
| contextPath | ../context | Override with custom context type. Currently must include field connection: Connection.  Note:  path must be relative to generated root directory. |

# Example usage code
See src/cli.ts

# Example outputs
Located within folders generatedTS and generatedJS.

# TODO
- Handle resolvers as normal vs connections. (Naming convention? New directive? Either?)
- Finish adding/handling EntitySchemaOptions (indices, etc...)

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