so I am trying to inject dependencies into classes that extend these types and I am getting runtime errors when I request a schema refresh saying that it cannot create my object. Heres what I am trying to do:
public class SomeResultType : ObjectType<SomeResult>
{
private readonly IMyDependency _md;
public SomeResult(IMYDependency md)
{
_md= md;
}
protected override void Configure(IObjectTypeDescriptor<QuoteResult> descriptor)
{
md.domSomething(); // this dependency is meant to dynamically set the class and field descriptions based on database tables so we can remove schema description from out codebase.
}
}
this is the error I get.
. Unable to create instance of type SomeResultType
.
I recognize that hotchocolate documentation advises against injecting dependencies into these ObjectType extensions, but I feel my use case is acceptable. Please tell me if this is just outright impossible because the documentation simply advises against it does not say you cannot do this. I suspect I am making a mistake somewhere in my Startup.cs file. Here is the Startup.cs file (note i have removed some dependencies because i cant share the entirety of the app):
services.AddDbContext<AbcContext>(opt => opt.UseSqlServer(Configuration.GetConnectionString("abc")).UseLazyLoadingProxies());
services.AddScoped<ISomeDependency, SomeDependency()>();
services.AddGraphQLServer()
.AddDefaultTransactionScopeHandler()
.AddHttpRequestInterceptor<HttpRequestInterceptor>()
.AddErrorFilter<GraphQLErrorFilter>()
.AddType<SomeResultType>()
.AddFiltering()
//.AddAuthorization()
.AddProjections()
.AddMutationType<PurchaseMutation>();
Thanks for reading, Im fairly new to graphql so I greatly appreciate your time and insights.