-
-
Notifications
You must be signed in to change notification settings - Fork 736
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added new dependency injection configuration API (#1971)
- Loading branch information
1 parent
c12223b
commit 7f63f0d
Showing
200 changed files
with
5,815 additions
and
1,332 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
{ | ||
"sdk": { | ||
"version": "3.1.201" | ||
"version": "3.1.300" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
74 changes: 74 additions & 0 deletions
74
src/HotChocolate/Core/benchmark/Execution.Benchmarks/DefaultExecutionPipelineBenchmark.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
using BenchmarkDotNet.Attributes; | ||
using System.Collections.Generic; | ||
using System.Buffers; | ||
using Microsoft.Extensions.DependencyInjection; | ||
using HotChocolate.StarWars; | ||
using System.Threading.Tasks; | ||
using System; | ||
using HotChocolate.Language; | ||
using System.Text; | ||
|
||
namespace HotChocolate.Execution.Benchmarks | ||
{ | ||
[RPlotExporter, CategoriesColumn, RankColumn, MeanColumn, MedianColumn, MemoryDiagnoser] | ||
public class DefaultExecutionPipelineBenchmark | ||
{ | ||
private readonly IRequestExecutor _executor; | ||
private readonly IReadOnlyQueryRequest _request; | ||
|
||
public DefaultExecutionPipelineBenchmark() | ||
{ | ||
var services = new ServiceCollection() | ||
.AddStarWarsRepositories() | ||
.AddGraphQL() | ||
.ConfigureSchema(b => b.AddStarWarsTypes()) | ||
.Services.BuildServiceProvider(); | ||
|
||
_executor = services | ||
.GetRequiredService<IRequestExecutorResolver>() | ||
.GetRequestExecutorAsync().Result; | ||
|
||
var md5 = new MD5DocumentHashProvider(); | ||
var resources = new ResourceHelper(); | ||
string introspectionQuery = resources.GetResourceString("IntrospectionQuery.graphql"); | ||
string hash = md5.ComputeHash(Encoding.UTF8.GetBytes(introspectionQuery).AsSpan()); | ||
DocumentNode document = Utf8GraphQLParser.Parse(introspectionQuery); | ||
_request = QueryRequestBuilder.New() | ||
.SetQuery(document) | ||
.SetQueryHash(hash) | ||
.SetQueryName(hash) | ||
.Create(); | ||
|
||
SchemaIntrospection().Wait(); | ||
} | ||
|
||
[Benchmark] | ||
public async Task SchemaIntrospection() | ||
{ | ||
IExecutionResult result = await _executor.ExecuteAsync(_request); | ||
// var jsonWriter = new HotChocolate.Execution.Serialization.JsonQueryResultSerializer(true); | ||
// Console.WriteLine(jsonWriter.Serialize((IReadOnlyQueryResult)result)); | ||
((IDisposable)result).Dispose(); | ||
} | ||
|
||
[Benchmark] | ||
public async Task SchemaIntrospectionMultiple() | ||
{ | ||
Task<IExecutionResult> task1 = _executor.ExecuteAsync(_request); | ||
Task<IExecutionResult> task2 = _executor.ExecuteAsync(_request); | ||
Task<IExecutionResult> task3 = _executor.ExecuteAsync(_request); | ||
Task<IExecutionResult> task4 = _executor.ExecuteAsync(_request); | ||
Task<IExecutionResult> task5 = _executor.ExecuteAsync(_request); | ||
|
||
((IDisposable)(await task1)).Dispose(); | ||
((IDisposable)(await task2)).Dispose(); | ||
task1 = _executor.ExecuteAsync(_request); | ||
((IDisposable)(await task3)).Dispose(); | ||
task2 = _executor.ExecuteAsync(_request); | ||
((IDisposable)(await task4)).Dispose(); | ||
((IDisposable)(await task5)).Dispose(); | ||
((IDisposable)(await task1)).Dispose(); | ||
((IDisposable)(await task2)).Dispose(); | ||
} | ||
} | ||
} |
24 changes: 21 additions & 3 deletions
24
src/HotChocolate/Core/benchmark/Execution.Benchmarks/Program.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,28 @@ | ||
using BenchmarkDotNet.Running; | ||
using System.Threading.Tasks; | ||
using BenchmarkDotNet.Running; | ||
|
||
namespace HotChocolate.Execution.Benchmarks | ||
{ | ||
class Program | ||
{ | ||
static void Main(string[] args) => | ||
BenchmarkRunner.Run<VariableCoercionBenchmarks>(); | ||
|
||
static void Main(string[] args) => | ||
BenchmarkRunner.Run<DefaultExecutionPipelineBenchmark>(); | ||
|
||
|
||
/* | ||
static async Task Main(string[] args) | ||
{ | ||
var bench = new DefaultExecutionPipelineBenchmark(); | ||
for (int i = 0; i < 1000; i++) | ||
{ | ||
await bench.SchemaIntrospection(); | ||
} | ||
} | ||
*/ | ||
|
||
} | ||
} |
35 changes: 35 additions & 0 deletions
35
src/HotChocolate/Core/src/Abstractions/ErrorHandlerExtensions.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
|
||
namespace HotChocolate | ||
{ | ||
public static class ErrorHandlerExtensions | ||
{ | ||
public static IEnumerable<IError> Handle( | ||
this IErrorHandler errorHandler, | ||
IEnumerable<IError> errors) | ||
{ | ||
if (errorHandler == null) | ||
{ | ||
throw new ArgumentNullException(nameof(errorHandler)); | ||
} | ||
|
||
if (errors == null) | ||
{ | ||
throw new ArgumentNullException(nameof(errors)); | ||
} | ||
|
||
return HandleEnumerator(errorHandler, errors); | ||
} | ||
|
||
private static IEnumerable<IError> HandleEnumerator( | ||
IErrorHandler errorHandler, | ||
IEnumerable<IError> errors) | ||
{ | ||
foreach (IError error in errors) | ||
{ | ||
yield return errorHandler.Handle(error); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 0 additions & 11 deletions
11
src/HotChocolate/Core/src/Abstractions/Execution/IResult.cs
This file was deleted.
Oops, something went wrong.
21 changes: 21 additions & 0 deletions
21
src/HotChocolate/Core/src/Abstractions/Execution/IResultMemoryOwner.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
using System; | ||
|
||
#nullable enable | ||
|
||
namespace HotChocolate.Execution | ||
{ | ||
/// <summary> | ||
/// This interface represents the owner of the rented objects associated | ||
/// with the result data structure. | ||
/// | ||
/// When this object is disposed it will return the objects representing the | ||
/// <see cref="Data" /> object structure back to the object pools. | ||
/// </summary> | ||
public interface IResultMemoryOwner : IDisposable | ||
{ | ||
/// <summary> | ||
/// The data object structure representing the GraphQL result. | ||
/// </summary> | ||
IResultMap? Data { get; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.