I am writing a graphql api using .net core+hot chocolate. I have to define all service names while creating graphql server. I have more than 20 service classes. Is there a generic way of specifying these services, I dont want to write 20 + lines of code to specify each service name.
Asked
Active
Viewed 17 times
0
-
1You can use reflection to find types that have a specific name, implement a specific interface or have a specific attribute and register them using the [non-generic versions](https://learn.microsoft.com/en-us/dotnet/api/microsoft.extensions.dependencyinjection.servicecollectionserviceextensions.addscoped?view=dotnet-plat-ext-7.0#microsoft-extensions-dependencyinjection-servicecollectionserviceextensions-addscoped(microsoft-extensions-dependencyinjection-iservicecollection-system-type-system-type)) of `AddScoped` – Panagiotis Kanavos Aug 22 '23 at 16:41