2.2.0 • Published 5 years ago

graphql_typeorm v2.2.0

Weekly downloads
6
License
ISC
Repository
github
Last release
5 years ago

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

NameOptionsDescription
@EntityEntitySchemaOptionsDetermines what GraphQL Types get converted to TypeORM EntitySchema Models.
@ColumnEntitySchemaColumnOptionsDetermines what model fields are stored in database.
@RelationshipEntitySchemaRelationshipOptionsDetermines that a relationship field should be created.
@PrimaryColumnEntitySchemaColumnOptionsShortcut for Column type with primary = true
@PrimaryGeneratedColumnEntitySchemaColumnOptionsShortcut for Column type with primary = true and generated = true
@CreateDateColumnEntitySchemaColumnOptionsShortcut for Column type with type = 'timestamp with time zone' and createDate = true
@UpdateDateColumnEntitySchemaColumnOptionsShortcut 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)

OptionDefaultDescription
file.graphql schema file to generate from
dirDirectory to find .graphql files to generate from
outDir./generatedDirectory to write generated files to
formattsOutput format. Valid options = ts/js
contextPath../contextOverride 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...)
2.2.0

5 years ago

2.1.0

5 years ago

2.0.4

5 years ago

2.0.3

5 years ago

2.0.2

5 years ago

2.0.1

5 years ago

2.0.0

5 years ago

1.1.0

6 years ago

1.0.4

6 years ago

1.0.3

6 years ago

1.0.2

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago