Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Schema Stitching Refinements (#2526)
- Loading branch information
1 parent
5a35105
commit 601190b
Showing
68 changed files
with
1,348 additions
and
392 deletions.
There are no files selected for viewing
22 changes: 22 additions & 0 deletions
22
...ore/src/AspNetCore/Extensions/HotChocolateAspNetCoreServiceCollectionExtensions.Warmup.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,22 @@ | ||
using System; | ||
using HotChocolate.AspNetCore.Utilities; | ||
using HotChocolate.Execution.Configuration; | ||
|
||
namespace Microsoft.Extensions.DependencyInjection | ||
{ | ||
public static partial class HotChocolateAspNetCoreServiceCollectionExtensions | ||
{ | ||
public static IRequestExecutorBuilder InitializeOnStartup( | ||
this IRequestExecutorBuilder builder) | ||
{ | ||
if (builder is null) | ||
{ | ||
throw new ArgumentNullException(nameof(builder)); | ||
} | ||
|
||
builder.Services.AddHostedService<ExecutorWarmupTask>(); | ||
builder.Services.AddSingleton(new WarmupSchema(builder.Name)); | ||
return builder; | ||
} | ||
} | ||
} |
1 change: 1 addition & 0 deletions
1
...AspNetCore/src/AspNetCore/Extensions/HotChocolateAspNetCoreServiceCollectionExtensions.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
44 changes: 44 additions & 0 deletions
44
src/HotChocolate/AspNetCore/src/AspNetCore/Utilities/ExecutorWarmupTask.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,44 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Threading; | ||
using System.Threading.Tasks; | ||
using HotChocolate.Execution; | ||
using Microsoft.Extensions.Hosting; | ||
|
||
namespace HotChocolate.AspNetCore.Utilities | ||
{ | ||
internal class ExecutorWarmupTask : BackgroundService | ||
{ | ||
private readonly IRequestExecutorResolver _executorResolver; | ||
private readonly HashSet<NameString> _schemaNames; | ||
|
||
public ExecutorWarmupTask( | ||
IRequestExecutorResolver executorResolver, | ||
IEnumerable<WarmupSchema> schemas) | ||
{ | ||
if (executorResolver is null) | ||
{ | ||
throw new ArgumentNullException(nameof(executorResolver)); | ||
} | ||
|
||
if (schemas is null) | ||
{ | ||
throw new ArgumentNullException(nameof(schemas)); | ||
} | ||
|
||
_executorResolver = executorResolver; | ||
_schemaNames = new HashSet<NameString>(schemas.Select(t => t.SchemaName)); | ||
} | ||
|
||
protected override async Task ExecuteAsync(CancellationToken stoppingToken) | ||
{ | ||
foreach (NameString schemaName in _schemaNames) | ||
{ | ||
await _executorResolver | ||
.GetRequestExecutorAsync(schemaName, stoppingToken) | ||
.ConfigureAwait(false); | ||
} | ||
} | ||
} | ||
} |
12 changes: 12 additions & 0 deletions
12
src/HotChocolate/AspNetCore/src/AspNetCore/Utilities/WarmupSchema.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,12 @@ | ||
namespace HotChocolate.AspNetCore.Utilities | ||
{ | ||
internal class WarmupSchema | ||
{ | ||
public WarmupSchema(NameString schemaName) | ||
{ | ||
SchemaName = schemaName; | ||
} | ||
|
||
public NameString SchemaName { get; } | ||
} | ||
} |
26 changes: 10 additions & 16 deletions
26
...ion/NamedRequestExecutorFactoryOptions.cs → ...guration/ConfigureRequestExecutorSetup.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
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
34 changes: 0 additions & 34 deletions
34
src/HotChocolate/Core/src/Execution/Configuration/RequestExecutorFactoryOptions.cs
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.