Configuration
rootModule
Configure the entry point of your dependency graph.
rootModule (Optional)
The rootModule option defines the graph entry point. This is the module from which all dependency resolution begins.
rootModule?: Type;
Typically, this is your application's main AppModule.
However, because Nest Graph Inspector uses ConfigurableModuleBuilder, you usually don't need to specify this option. The module where you import NestGraphInspector.forRoot() will automatically be inferred as the rootModule.
How it Works
Starting from the root module, Nest Graph Inspector:
- Reads the module's imports
- Recursively traverses all imported modules
- Collects providers, controllers, and their dependencies
- Builds the complete dependency graph
Example
app.module.ts
import { Module } from '@nestjs/common';
import { UsersModule } from './users/users.module';
import { AuthModule } from './auth/auth.module';
import { NestGraphInspector } from 'nest-graph-inspector';
@Module({
imports: [
UsersModule,
AuthModule,
NestGraphInspector.forRoot()
],
})
export class AppModule {}
By default, the graph will automatically include AppModule, UsersModule, AuthModule, and all their transitive dependencies without needing to explicitly define rootModule.
