Skip to content

Commit 41979c5

Browse files
authored
Reworked fusion configuration to use observer. (#6310)
1 parent 383814e commit 41979c5

25 files changed

+631
-280
lines changed

src/HotChocolate/Core/src/Execution/Configuration/ITypeModule.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,11 @@ public abstract class TypeModule : ITypeModule
5050
/// </summary>
5151
public event EventHandler<EventArgs>? TypesChanged;
5252

53+
internal virtual ValueTask ConfigureAsync(
54+
ConfigurationContext context,
55+
CancellationToken cancellationToken)
56+
=> default;
57+
5358
/// <summary>
5459
/// Will be called by the schema building process to add the dynamically created
5560
/// types and type extensions to the schema building process.

src/HotChocolate/Core/src/Execution/RequestExecutorResolver.cs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,10 @@ await OnConfigureRequestExecutorOptionsAsync(context, setup, cancellationToken)
243243
typeModuleChangeMonitor.Register(typeModule);
244244
}
245245

246+
// we allow newer type modules to apply configurations.
247+
await typeModuleChangeMonitor.ConfigureAsync(context, cancellationToken)
248+
.ConfigureAwait(false);
249+
246250
serviceCollection.AddSingleton<IApplicationServiceProvider>(
247251
_ => new DefaultApplicationServiceProvider(_applicationServices));
248252

@@ -519,6 +523,20 @@ public void Register(ITypeModule typeModule)
519523
_typeModules.Add(typeModule);
520524
}
521525

526+
internal async ValueTask ConfigureAsync(
527+
ConfigurationContext context,
528+
CancellationToken cancellationToken)
529+
{
530+
foreach (var item in _typeModules)
531+
{
532+
if (item is TypeModule typeModule)
533+
{
534+
await typeModule.ConfigureAsync(context, cancellationToken)
535+
.ConfigureAwait(false);
536+
}
537+
}
538+
}
539+
522540
public IAsyncEnumerable<ITypeSystemMember> CreateTypesAsync(IDescriptorContext context)
523541
=> new TypeModuleEnumerable(_typeModules, context);
524542

src/HotChocolate/Fusion/src/Core/Clients/IGraphQLClient.cs

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
using HotChocolate.Fusion.Metadata;
2-
31
namespace HotChocolate.Fusion.Clients;
42

53
/// <summary>
@@ -28,16 +26,3 @@ Task<GraphQLResponse> ExecuteAsync(
2826
GraphQLRequest request,
2927
CancellationToken cancellationToken);
3028
}
31-
32-
/// <summary>
33-
/// Represents a factory for creating <see cref="IGraphQLClient"/> instances.
34-
/// </summary>
35-
public interface IGraphQLClientFactory
36-
{
37-
/// <summary>
38-
/// Creates a new <see cref="IGraphQLClient"/> instance.
39-
/// </summary>
40-
/// <param name="configuration"></param>
41-
/// <returns></returns>
42-
IGraphQLClient CreateClient(HttpClientConfiguration configuration);
43-
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
using HotChocolate.Fusion.Metadata;
2+
3+
namespace HotChocolate.Fusion.Clients;
4+
5+
/// <summary>
6+
/// Represents a factory for creating <see cref="IGraphQLClient"/> instances.
7+
/// </summary>
8+
public interface IGraphQLClientFactory
9+
{
10+
/// <summary>
11+
/// Creates a new <see cref="IGraphQLClient"/> instance.
12+
/// </summary>
13+
/// <param name="configuration"></param>
14+
/// <returns></returns>
15+
IGraphQLClient CreateClient(HttpClientConfiguration configuration);
16+
}

src/HotChocolate/Fusion/src/Core/DependencyInjection/FileWatcherTypeModule.cs

Lines changed: 0 additions & 61 deletions
This file was deleted.

0 commit comments

Comments
 (0)