Kind: Interface
Source: packages/common/interfaces/nest-application-context.interface.ts
Part of: Common
GetOrResolveOptions configures how a Nest application context looks up or resolves providers. Use strict to control whether resolution is limited to the current module context, and each to request all matching provider instances instead of a single result.
Properties
| Property | Type |
|---|---|
strict | boolean |
each | boolean |
Diagram
mermaidgraph LR A[Application Context] --> B[GetOrResolveOptions] B --> C[strict: boolean] B --> D[each: boolean] C --> E[Limit lookup to current module context] D --> F[Return one or all matching providers]
Usage
tsimport { NestFactory } from '@nestjs/core';
import { GetOrResolveOptions } from '@nestjs/common';
const options: GetOrResolveOptions = {
strict: false,
each: true,
};
const app = await NestFactory.createApplicationContext(AppModule);
// Search across module boundaries and return every matching provider.
const handlers = app.get(MyHandlerToken, options);
handlers.forEach((handler) => handler.handle());
AI Coding Instructions
- Set
strict: truewhen a provider must be resolved only from the current module context. - Use
strict: falsefor cross-module provider lookup when providers are exported through imported modules. - Set
each: trueonly when multiple providers may share the requested token; handle the returned collection accordingly. - Keep provider tokens and expected return types aligned, especially when using custom injection tokens.
- Prefer explicit options when lookup behavior is important to avoid unintended module-boundary resolution.
Used by
2 references from 2 files. Each is a place in this repository where the symbol is actually used — go read one rather than trusting an example.
Imported by (2)
AbstractInstanceResolver—packages/core/injector/abstract-instance-resolver.ts:12NestApplicationContext—packages/core/nest-application-context.ts:40
Was this page helpful?