Open attilavetesi-epam opened 7 months ago
Correction: when adding a ServiceD
as the first parameter to the /works3
method (after the current ServiceC
parameter), the problem can be also reproduced (i.e. ServiceA
is not injected correctly).
Summary: seemingly only at the first injection a @context_dependency_definition is recognized, in all other cases (where some other injections are finalized beforehand) the @context_dependency_definition is not detected/used anymore.
When using FastAPI, the @context_dependency_definition decorator is not considered for constructing the type if the given type is not injected before other injections in the route definition.
Consider the following code:
In the following cases the injection works as expected:
Unfortunately in the case when the ServiceA is injected in the FastAPI method, but there are other injections happening beforehand, the following error is thrown, which suggests that the @context_dependency_definition is disregarded and the init of ServiceA is planned to be called directly.