Is Dependency Injection in a Hot Chocolate Web Application static, or per-instance?

169 Views Asked by At

I have a general architectural enquiry about Hot Chocolate. I'm hoping the answer may tell me whether I've made incorrect assumptions or have taken a wrong turn somewhere else.

I am building a simulation system providing stateful generated data for mocking external APIs in a complex distributed system in the energy sector. Each instance of a clustered simulation engine hosts every simulation that is running. One feature of the system is to expose for each simulation a unique GraphQL API providing access to the simulation's generated data (using Hot Chocolate). All data is generated into Azure CosmosDB and repos providing access to each DB are injected into the appropriate Hot Chocolate Web App instance during its initial building stage.

A key point is that at any one time the simulation hosting process is exposing multiple GraphQL APIs on different ports. As a request comes in on a port, I expect the web app exposing that port to have the correct repos injected into it. Instead, I find that regardless of what port/webapp I come in on, the same repos get injected. That is, I always get given the repo for database A, even though I should have been given the repo for database B because I came in on port b.

My question is - is this architecture going to work for me? Is the DI for web apps stored in some kind of static variable? Or is it per web app instance? Should I expect to get the right repo?

0

There are 0 best solutions below