feat: configure dependency lookup in parent container
Is it possible to configure typedi to lookup dependencies in the parent container rather than having to do explicit container.set for all the named services?
Our team would also find this useful. child = container.child() or the like.
Can you please provide a minimal example of your desired behavior? Including what would you like to happen and what happens currently.
What i think he meant is this:
What happens currently:
Container.set('foo', 'bar');
Container.get('foo') === 'bar'; // true
Container.of('random').get('foo') === 'bar'; // ServiceNotFoundError
What would like to happen:
Container.set('foo', 'bar');
Container.get('foo') === 'bar'; // true
Container.of('random').get('foo') === 'bar'; // true
I have the same use case. I have some service that can be registered into the global namespace (Container.set), but I also have a container that depends on the request taht contains a DB service. I'm using it in conjunction with type-graphql (https://typegraphql.com/docs/dependency-injection.html#scoped-containers) and I can tell it only about one container. Of course I configure it to use the scoped container. How can I access what I define in the global scope? Is this an anti-pattern? Is there any other way to achieve this or should I declare everything in the scoped container?