How to prevent error "No provider for xxx! - in Module "xxx" (Operation Scope)" when adding new provider #2223
Unanswered
alexxiyang
asked this question in
Q&A
Replies: 1 comment
-
Can anyone help us? |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Recently our project team met an issue.
Scenario
There are 2 modules
ModuleA
andModuleB
.ModuleA
has a providerProviderFoo
.ProviderFoo
usesRESTDataSourceA
which is also a providerModuleB
has a providerProviderBar
which usesProviderFoo
ofModuleA
The design looks like below
Recently, we add a new
RESTDataSourceB
.ProviderFoo
usesRESTDataSourceB
as well. But we forgot to register theRESTDataSourceB
inModuleB
. Then we got this errorNo provider for RESTDataSourceB! - in Module "ModuleB" (Operation Scope)
Because we can't prevent engineers from making similar mistakes when adding a new
Provider
. QA will only testModuleA
if this change is made forModuleA
. How to prevent the same issue happen again?The solution I can think about is create a
allProviders.ts
. Include all the providers in this file likeBut it's an ugly solution. Is there any better solution can fix this issue?
Beta Was this translation helpful? Give feedback.
All reactions