# pg-graphql-typeorm

> Easily generate graphql typeorm entities with one command

Latest version **0.5.5** (published 2025-04-16) · MIT license · 0 weekly downloads

## Install

```sh
npm install pg-graphql-typeorm
pnpm add pg-graphql-typeorm
yarn add pg-graphql-typeorm
bun add pg-graphql-typeorm
```

Provides the command `ftl`.

## Health

**Score 25/100 (F)** — status: maintenance-mode.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: stale; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.5.5 |
| Published | 2025-04-16 |
| First published | 2021-08-22 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 14 |
| Unpacked size | 483.9 KB |
| Known vulnerabilities | 0 (+4 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 1 |
| Author | Cameron Ellis |
| Maintainers | cellis |

## Links

- npm: https://www.npmjs.com/package/pg-graphql-typeorm
- Repository: https://github.com/cellis/pg-graphql-typeorm
- Homepage: https://github.com/cellis/pg-graphql-typeorm#readme
- Issues: https://github.com/cellis/pg-graphql-typeorm/issues
- npm.io page: https://npm.io/package/pg-graphql-typeorm

## Dependencies (14)

- [q](https://npm.io/package/q.md) ^1.5.1
- [pg](https://npm.io/package/pg.md) ^8.5.1
- [path](https://npm.io/package/path.md) ^0.12.7
- [chalk](https://npm.io/package/chalk.md) ^4.1.0
- [clear](https://npm.io/package/clear.md) ^0.1.0
- [yargs](https://npm.io/package/yargs.md) ^16.2.0
- [dedent](https://npm.io/package/dedent.md) ^0.7.0
- [figlet](https://npm.io/package/figlet.md) ^1.5.0
- [lodash](https://npm.io/package/lodash.md) ^4.17.21
- [pgtools](https://npm.io/package/pgtools.md) ^0.3.1
- [typeorm](https://npm.io/package/typeorm.md) ^0.2.31
- [pluralize](https://npm.io/package/pluralize.md) ^8.0.0
- [@wmfs/pg-info](https://npm.io/package/@wmfs/pg-info.md) ^1.19.0
- [typescript-require](https://npm.io/package/typescript-require.md) ^0.3.0

## Recent versions

- 0.5.5 (latest) — 2025-04-16
- 0.5.3 — 2025-02-21
- 0.5.0 — 2023-09-02
- 0.4.2 — 2023-07-06
- 0.4.1 — 2023-04-20
- 0.3.7 — 2022-08-10
- 0.3.6 — 2021-11-23
- 0.3.5 — 2021-11-12
- 0.3.4 — 2021-09-04
- 0.3.3 — 2021-09-04
- 0.3.2 — 2021-09-04
- 0.3.1 — 2021-08-22
- 0.3.0 — 2021-08-22

## README

## pg-graphql-typeorm 

The sole purpose of this code as of inception, is to generate typeorm + typegraphql models from a postgres database.

I followed [creating a cli with nodejs](https://itnext.io/how-to-create-your-own-typescript-cli-with-node-js-1faf7095ef89), [creating a cli with typescript](https://medium.com/rubber-ducking/creating-a-cli-with-typescript-1c5112ae101f), and [unit testing node cli apps](https://medium.com/@altshort/unit-testing-node-cli-apps-with-jest-2cd4adc599fb) to help create this so shout out to those authors. 


### Usage

```
yarn ftl -d my_database -s schema_1,schema_2,schema_n -o ./where/toput/entities
```

### Usage with prettier (optional)

```
yarn ftl -d my_database -s schema_1,schema_2,schema_n -o ./where/toput/entities && yarn typeorm:format
```

Note: `typeorm:format` is just package.json script with `prettier --write ./src/generated/entities/*.ts`

I like to add a script to my package.json:

```
"scripts": {
...
  "build:entities": "yarn ftl -d my_database -s schema_1,schema_2,schema_n -o ./src/generated/entities && yarn typeorm:format"
}
```

### Todo

- [x] Allow configs. Loading configs works but haven't decided on to do with the configuration. E.g., exclude some tables from generation, or specific columns in a table or even some pattern type stuff.

Update in version 0.5.0 load config (.ftlrc.js in root project) to decide whether to create relationships for a certain field of a model.


### Compatibility

TypeORM: 0.2.32
TypeGraphql: 1.1.1

### Notes on development

This was originally called `superluminal`, but upon trying to publish i noticed that cool name was taken so i renamed. The `ftl` command will stay though ;)

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