useGenerated

CLI that lets you build a fully customizable CRUD GraphQL API in minutes not weeks.
- Define your data models
- Describe your API in a config file
- Run a command that auto-generates all the code
Tech stack : Prisma ORM + NestJS
Extract from README.md
Getting started - Initial setup
1. Create a NestJs App npm i -g @nestjs/cli
and nest new project-name
,
2. replace the package.json
with the one received with this module
3. Add the use-generated-cli
folder at the same level as the NestJs app and run yarn
or npm install
4. Run yarn use-generated init
Developing workflow
1. Define your models in prisma/schema.prisma
.
Please make sure you have a postgres database created and it matches .env
config for more info please consult Prisma docs[https://pris.ly/d/prisma-schemaaccessing-environment-variables-from-the-schema]).
2. Create and apply prisma migrations yarn prisma migrate dev
.
This will also regenerate prisma client and the NestJs GraphQL types in the src/@generated
folder based on the generator.
3. Define your api in use-generated-config/appconfig.json
.
You could use the config from use-generated-config/appconfig_example.json
along with copying the contents of use-generated-config/schema.prisma__example
to prisma/schema.prisma
as a working starting point. Also if auth module is used make sure you have SALT
and JWT_SECRET
in .env
defined as per .env__example
4. Run yarn use-generated api
to generate the api
5. Run yarn start:dev
to start the development server
GraphQL API and props
With this CLI you will be able to create a fully customizable and extendable Graphql CRUD API just by defining the database or data models and a configuration file
Resolvers
1. allUsers
- accepts properties:
- perPage
- used for pagination
- skip
- used for pagination
- orderBy
sorting / ordering, matches the Prisma ORM orderBy
API
- where
filtering matches the Prisma ORM where
- nestedArgs
defines the perPage
, skip
,`orderBy` and where
for the nested relations
Config example
CLI that lets you build a fully customizable CRUD GraphQL API in minutes not weeks.