diff --git a/src/GraphQL.Conventions/Web/IRequestHandler.cs b/src/GraphQL.Conventions/Web/IRequestHandler.cs index 81f6bf76..d4ef236f 100644 --- a/src/GraphQL.Conventions/Web/IRequestHandler.cs +++ b/src/GraphQL.Conventions/Web/IRequestHandler.cs @@ -4,7 +4,7 @@ namespace GraphQL.Conventions.Web { public interface IRequestHandler { - Task ProcessRequest(Request request, IUserContext userContext); + Task ProcessRequest(Request request, IUserContext userContext, IDependencyInjector dependencyInjector = null); Response Validate(Request request); diff --git a/src/GraphQL.Conventions/Web/RequestHandler.cs b/src/GraphQL.Conventions/Web/RequestHandler.cs index 66f1bdd3..c6fac0b8 100644 --- a/src/GraphQL.Conventions/Web/RequestHandler.cs +++ b/src/GraphQL.Conventions/Web/RequestHandler.cs @@ -230,14 +230,14 @@ internal RequestHandlerImpl( } } - public async Task ProcessRequest(Request request, IUserContext userContext) + public async Task ProcessRequest(Request request, IUserContext userContext, IDependencyInjector dependencyInjector = null) { var result = await _engine .NewExecutor() .WithQueryString(request.QueryString) .WithInputs(request.Variables) .WithOperationName(request.OperationName) - .WithDependencyInjector(_dependencyInjector) + .WithDependencyInjector(dependencyInjector ?? _dependencyInjector) .WithUserContext(userContext) .WithComplexityConfiguration(_complexityConfiguration) .EnableValidation(_useValidation) diff --git a/test/Tests/Web/RequestHandlerTests.cs b/test/Tests/Web/RequestHandlerTests.cs index 3a4fb3dd..2c8007a4 100644 --- a/test/Tests/Web/RequestHandlerTests.cs +++ b/test/Tests/Web/RequestHandlerTests.cs @@ -17,7 +17,7 @@ public async Task Can_Run_Query() .New() .WithQuery() .Generate() - .ProcessRequest(request, null); + .ProcessRequest(request, null, null); response.ExecutionResult.Data.ShouldHaveFieldWithValue("hello", "World"); response.Body.ShouldEqual("{\"data\":{\"hello\":\"World\"}}"); @@ -34,7 +34,7 @@ public async Task Can_Run_Simple_Query_Using_ComplexityConfiguration() .WithQuery() .WithComplexityConfiguration(new ComplexityConfiguration { MaxDepth = 2 }) .Generate() - .ProcessRequest(request, null); + .ProcessRequest(request, null, null); response.ExecutionResult.Data.ShouldHaveFieldWithValue("hello", "World"); response.Body.ShouldEqual("{\"data\":{\"hello\":\"World\"}}"); @@ -51,7 +51,7 @@ public async Task Cannot_Run_Too_Complex_Query_Using_ComplexityConfiguration() .WithQuery() .WithComplexityConfiguration(new ComplexityConfiguration { MaxDepth = 1 }) .Generate() - .ProcessRequest(request, null); + .ProcessRequest(request, null, null); response.Errors.Count.ShouldEqual(1); response.Errors[0].Message.ShouldEqual("Query is too nested to execute. Depth is 2 levels, maximum allowed on this endpoint is 1."); @@ -66,7 +66,7 @@ public async Task Can_Enrich_With_Profiling_Information() .WithQuery() .WithProfiling() .Generate() - .ProcessRequest(request, null); + .ProcessRequest(request, null, null); response.EnrichWithProfilingInformation(); response.Body.ShouldContain("\"extensions\":{\"profile\":"); } @@ -80,7 +80,7 @@ public async Task Can_Ignore_Types_From_Unwanted_Namespaces() .New() .WithQuery() .Generate() - .ProcessRequest(request, null); + .ProcessRequest(request, null, null); response.Body.ShouldEqual("{\"data\":{\"earth\":{\"hello\":\"World\"},\"mars\":{\"hello\":\"World From Mars\"}}}"); // Exclude types from 'Unwanted' namespace, i.e. TypeQuery2 from CompositeQuery schema @@ -90,7 +90,7 @@ public async Task Can_Ignore_Types_From_Unwanted_Namespaces() .IgnoreTypesFromNamespacesStartingWith("GraphQL.Conventions.Tests.Web.Unwanted") .WithQuery() .Generate() - .ProcessRequest(request, null); + .ProcessRequest(request, null, null); response.Errors.Count.ShouldEqual(1); response.Errors[0].Message.ShouldContain("Cannot query field \"hello\" on type \"TestQuery2\"."); response.Body.ShouldContain("VALIDATION_ERROR");