Gent is a lightweight, reusable business logic layer that makes it easy to build GraphQL servers in Node.js and TypeScript.
- It uses MikroORM and Knex to work with SQL databases.
- Some requests can be batched with Dataloader.
- Authorization checks have first class support - write your own access control rules and Gent will use them when doing any CRUD operation.
- Gent makes extensive use of human-readable code generation to keep magic and opaque framework code to a minimum. More on this below.
We use @elg/tscodegen to generate models and boilerplate code based on an entity's schema.
There are many benefits to generating away your boilerplate code:
- A lot of functionality with just one
gentgen
execution: just create a schema, and Gent will generate typesafe and authorized classes for the entity. - Your boilerplate code will always be kept up to date - when the schema
changes or Gent gets an upgrade, a
gentgen
execution will be all you need to gain all that shiny new functionality. - Gent code is very easy to understand and debug, as they are meant for humans and are kept in your codebase.
- tscodegen allows you to modify generated code. You can thus extend the generated functionality without breaking abstraction barriers or causing subclasses to appear throughout your codebase. Subsequent code generations will preserve your manually written code. Well, mostly, but Git will save you the rest of the time.
Having said that, we know our limits; where possible, we implement functionality within Gent's framework code to prevent unnecessarily duplicating code.
# Clone this repo
git clone git@github.com:taneliang/gent.git
cd gent
yarn # Install dependencies
yarn link
# cd to your project directory
yarn link @elg/gent
TODO: This package isn't on NPM yet; the below commands won't work.
# npm install @elg/gent prettier # NPM
# yarn add @elg/gent prettier # Yarn
TODO:
Gent is heavily inspired by Facebook's open source Ent, as well as the below descriptions of Facebook's Ent framework: