The Mock Server is a lightweight and autonomous NestJS tool that dynamically generates mock GraphQL servers based on GraphQL data schemas. It is designed to simplify the process of creating mock servers for development and testing purposes.
- Instant creation of mocked servers based on GraphQL data schemas
- Highly configurable dynamic module for working with multiple schema files
- Easy integration with NestJS applications
- Node.js version 12.0 or higher
- NestJS version 8.0 or higher
To launch the project in a Docker container, run the command docker-compose up -d app
For adding the Mock Server module to your project, follow these steps:
-
Copy the
mock.module.ts
file into your project. -
Add the dynamic Mock Module to your app module and specify the path to the GraphQL data schemas.
import { Module } from '@nestjs/common'; import * as path from 'path'; import { MockModule } from './mock.module'; @Module({ imports: [ MockModule.register({ schemasPath: path.join(__dirname, '..', '..', 'data', 'schemas'), }), ], }) export class AppModule {}
-
Run npm
run start:dev
and enter the GraphQL playground with an endpoint similar to the name of a corresponding schema file.
For running the Mock Server as a standalone project:
- Fork and clone the repository to your local machine.
- Install dependencies by running
npm install
. - Run the server by running
npm run start:dev
.
Contributions to the Mock Module Tool for NestJS are always welcome. To contribute, please follow these steps:
- Fork the repository.
- Make your changes and write tests for them.
- Submit a pull request.
The Mock Module Tool for NestJS is licensed under the MIT License. See LICENSE
for more information.
This tool is intended for development and testing purposes only and should not be used in production environments.
The Mock Module Tool for NestJS was created by dasha.smyr@gmail.com and uxname@gmail.com