graphql-dotnet / graphql-dotnet/conventions

Support for scoped services being injected into schema types constructor

Open
#133 7 comments 5 reactions 0 assignees View on GitHub
question
Dominant language
C#
Stars
228
Forks
62
PR merge metrics
No merged PRs in 30d

Description

For now it is possible to set own dependency injector for executor using [WithDependencyInjector](https://github.com/graphql-dotnet/conventions/blob/master/src/GraphQL.Conventions/Adapters/Engine/GraphQLExecutor.cs#L90) method. Then using `InjectAttribute` for parameters of Query methods we can inject scoped services using provided dependency container.
But what if we need to share scoped services within whole Query class injecting them into constructor?
For now services injected into constructor of schema type are resolved using [typeResolutionDelegate](https://github.com/graphql-dotnet/conventions/blob/master/src/GraphQL.Conventions/Adapters/Engine/GraphQLEngine.cs#L79) provided into `GraphQLEngine` constructor. Engine mainly constructed one time and that's why there is no option to provide it with scoped services resolution (used in Microsoft ASP.NET Core dependency
container).
Is there any solution to use injector provided for executor by [WithDependencyInjector](https://github.com/graphql-dotnet/conventions/blob/master/src/GraphQL.Conventions/Adapters/Engine/GraphQLExecutor.cs#L90) method to resolve services for injection into constructor of schema types?

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.