Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add dependency injector parameter to IRequestHandler.ProcessRequest #127

Merged
merged 1 commit into from
Feb 16, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/GraphQL.Conventions/Web/IRequestHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ namespace GraphQL.Conventions.Web
{
public interface IRequestHandler
{
Task<Response> ProcessRequest(Request request, IUserContext userContext);
Task<Response> ProcessRequest(Request request, IUserContext userContext, IDependencyInjector dependencyInjector = null);

Response Validate(Request request);

Expand Down
4 changes: 2 additions & 2 deletions src/GraphQL.Conventions/Web/RequestHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -230,14 +230,14 @@ internal RequestHandlerImpl(
}
}

public async Task<Response> ProcessRequest(Request request, IUserContext userContext)
public async Task<Response> 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)
Expand Down
12 changes: 6 additions & 6 deletions test/Tests/Web/RequestHandlerTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public async Task Can_Run_Query()
.New()
.WithQuery<TestQuery>()
.Generate()
.ProcessRequest(request, null);
.ProcessRequest(request, null, null);

response.ExecutionResult.Data.ShouldHaveFieldWithValue("hello", "World");
response.Body.ShouldEqual("{\"data\":{\"hello\":\"World\"}}");
Expand All @@ -34,7 +34,7 @@ public async Task Can_Run_Simple_Query_Using_ComplexityConfiguration()
.WithQuery<TestQuery>()
.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\"}}");
Expand All @@ -51,7 +51,7 @@ public async Task Cannot_Run_Too_Complex_Query_Using_ComplexityConfiguration()
.WithQuery<TestQuery>()
.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.");
Expand All @@ -66,7 +66,7 @@ public async Task Can_Enrich_With_Profiling_Information()
.WithQuery<ProfiledQuery>()
.WithProfiling()
.Generate()
.ProcessRequest(request, null);
.ProcessRequest(request, null, null);
response.EnrichWithProfilingInformation();
response.Body.ShouldContain("\"extensions\":{\"profile\":");
}
Expand All @@ -80,7 +80,7 @@ public async Task Can_Ignore_Types_From_Unwanted_Namespaces()
.New()
.WithQuery<CompositeQuery>()
.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
Expand All @@ -90,7 +90,7 @@ public async Task Can_Ignore_Types_From_Unwanted_Namespaces()
.IgnoreTypesFromNamespacesStartingWith("GraphQL.Conventions.Tests.Web.Unwanted")
.WithQuery<CompositeQuery>()
.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");
Expand Down