Skip to content
/ gent Public

Reusable business logic base layer for GraphQL API servers written in TypeScript+Node.js

License

Notifications You must be signed in to change notification settings

taneliang/gent

Repository files navigation

Gent

CircleCI codecov Maintainability

Gent is a lightweight, reusable business logic layer that makes it easy to build GraphQL servers in Node.js and TypeScript.

Key Features

  1. It uses MikroORM and Knex to work with SQL databases.
  2. Some requests can be batched with Dataloader.
  3. Authorization checks have first class support - write your own access control rules and Gent will use them when doing any CRUD operation.
  4. Gent makes extensive use of human-readable code generation to keep magic and opaque framework code to a minimum. More on this below.

Code Generation

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:

  1. A lot of functionality with just one gentgen execution: just create a schema, and Gent will generate typesafe and authorized classes for the entity.
  2. 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.
  3. Gent code is very easy to understand and debug, as they are meant for humans and are kept in your codebase.
  4. 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.

Installation

# 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

Usage

TODO:

Inspiration

Gent is heavily inspired by Facebook's open source Ent, as well as the below descriptions of Facebook's Ent framework:

About

Reusable business logic base layer for GraphQL API servers written in TypeScript+Node.js

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published