DryerJS is a powerful library that allows you to generate CRUD GraphQL APIs in a declarative way, seamlessly integrating with Apollo Server, Mongoose, and MongoDB. With DryerJS, you can streamline the development of your GraphQL APIs and focus on your application's logic instead of writing repetitive boilerplate code.
- Declarative schema definition for GraphQL APIs.
- Integration with Apollo Server for GraphQL endpoint setup.
- Seamless interaction with MongoDB and Mongoose.
- Fine-grained control over input/output data transformation.
- Support for input validation and data manipulation.
- Easily customizable to fit your specific needs.
To get started with DryerJS, follow these steps:
-
Init NestJS project:
npm i -g @nestjs/cli && nest new my-project
-
Install dependencies:
npm i @nestjs/graphql @nestjs/apollo @apollo/server class-transformer class-validator @nestjs/mongoose
-
Install DryerJS as a dependency in your project
npm install dryerjs
-
Declare your first model on
src/user.ts
:import { Definition, Property } from 'dryerjs'; @Definition() export class User { @Property() id: string; @Property() email: string; @Property() password: string; @Property() name: string; }
-
Import your model and DryerJSModule in AppModule with other modules inside app.module.ts:
import { Module } from '@nestjs/common'; import { GraphQLModule } from '@nestjs/graphql'; import { ApolloDriver, ApolloDriverConfig } from '@nestjs/apollo'; import { MongooseModule } from '@nestjs/mongoose'; import { DryerModule } from 'dryerjs'; import { User } from './user'; @Module({ imports: [ GraphQLModule.forRoot<ApolloDriverConfig>({ driver: ApolloDriver, autoSchemaFile: true, playground: true, }), MongooseModule.forRoot('mongodb://127.0.0.1:27017/test'), DryerModule.register({ definitions: [User] }), ], }) export class AppModule {}
-
Start server
npm run start:dev
-
Open browser and go to http://localhost:3000/graphql to see the GraphQL playground.
-
Modify your model and see the changes in the GraphQL playground. Using Validate, Transform, Default, Enum, Embedded features to customize your model. Take a look at more complicated example models.
We are actively working on documentation. In the meantime, you can explore our example project to see DryerJS in action.
Please read CONTRIBUTING.md for details on our code of conduct, and the process for submitting pull requests to us.
This project is licensed under the MIT License - see the LICENSE file for details.