I'm attempting to integrate GrapQL.EntityFramework
using a DB first approach on an Azure Function. I've generated the needed contexts, User graphs, query, along with the function itself. Currently I'm having an issue with the Startup
file of my function app where I am to use dependency injection.
I've attempted both options on the configuration guide in the GraphQL.EntityFramework Docs. I've also made attempts at snippets of code such as builder.Services.AddSingleton(typeof(IEfGraphQLService<PersonarDBContext>),instance => { return new DBContext(); });
The current state of my startup file
public override void Configure(IFunctionsHostBuilder builder)
{
string connection = ""
builder.Services.AddTransient<UserQuery>();
builder.Services.AddDbContext<DBContext>(options => options.UseSqlServer(connection));
var optionBuilder = new DbContextOptionsBuilder<DBContext>();
optionBuilder.UseSqlServer(connection);
EfGraphQLConventions.RegisterInContainer<DBContext>(builder.Services, null);
EfGraphQLConventions.RegisterConnectionTypesInContainer(builder.Services);
builder.Services.AddSingleton(typeof(IEfGraphQLService<DBContext>),instance => { return new DBContext(); });
}
At this point in time I am just attempting to get my function app to startup properly. I am currently experiencing this error output.
User: Microsoft.Azure.WebJobs.Host: Error indexing method 'User'. Microsoft.Azure.WebJobs.Host: Cannot bind parameter 'service' to type IEfGraphQLService`1. Make sure the parameter Type is supported by the binding. If you're using binding extensions (e.g. Azure Storage, ServiceBus, Timers, etc.) make sure you've called the registration method for the extension(s) in your startup code (e.g. builder.AddAzureStorage(), builder.AddServiceBus(), builder.AddTimers(), etc.).
builder.Services.AddSingleton(typeof(IEfGraphQLService<DBContext>),instance => { return new DBContext(); });
. DoesDbContext
derive fromIEfGraphQLService<DBContext>
? I highly doubt. – Nkosi