-
-
Notifications
You must be signed in to change notification settings - Fork 7.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(core): add resolve method to load scoped classes #2682
Conversation
Pull Request Test Coverage Report for Build 3911
💛 - Coveralls |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let trace the issues #2049.Maybe should resolve scope provider.
@Module({
imports: [],
providers: [
{
scope: Scope.TRANSIENT,
provide: 'TRANSIENT_PROVIDER',
useFactory: () => {
// Does not get called
console.log('Called `TRANSIENT_PROVIDER`');
return 'TRANSIENT_PROVIDER_VALUE';
}
},
]
})
export class AppModule {}
async function bootstrap() {
const app = await NestFactory.createApplicationContext(AppModule);
// Returns `null`
app.get('TRANSIENT_PROVIDER')}
}
I meet error when test with this.
@underfin you should use |
@kamilmysliwiec Is it possible to use this in tests to fake Request-scoped providers? I would like to resolve services which depend on faked Request-scoped providers. |
Yes @ulrichb. I'm working on the docs for this now |
Okay, cool! Looking forward to this. |
@kamilmysliwiec, @ulrichb are the docs ready for this? cant seem to find them. |
@aevartg I think the docs for this will be written in nestjs/docs.nestjs.com#623 |
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
PR Checklist
Please check if your PR fulfills the following requirements:
PR Type
What kind of change does this PR introduce?
What is the current behavior?
Issue Number: N/A
What is the new behavior?
resolve()
method that allows loading both transient and request-scoped providers dynamicallyDoes this PR introduce a breaking change?
Other information