File tree Expand file tree Collapse file tree
tests/AppAny.HotChocolate.FluentValidation.Benchmarks Expand file tree Collapse file tree Original file line number Diff line number Diff line change 3434
3535 <ItemGroup Label =" Packages" >
3636 <PackageReference Include =" FluentValidation" Version =" 11.1.1" />
37- <PackageReference Include =" HotChocolate.Execution" Version =" 13.0.0-preview.66 " />
37+ <PackageReference Include =" HotChocolate.Execution" Version =" 13.0.0-preview.95 " />
3838 </ItemGroup >
3939
4040 <ItemGroup Label =" Assets" >
Original file line number Diff line number Diff line change @@ -18,9 +18,7 @@ public static IRequestExecutorBuilder AddFluentValidation(
1818
1919 builder . SetContextData ( ValidationDefaults . ValidationOptionsKey , validationOptions ) ;
2020
21- builder . OnBeforeCompleteType ( ValidationDefaults . Interceptors . OnBeforeCompleteType ) ;
22-
23- builder . OnAfterSchemaCreate ( ValidationDefaults . Interceptors . OnAfterSchemaCreate ) ;
21+ builder . TryAddTypeInterceptor ( ValidationDefaults . Interceptor ) ;
2422
2523 return builder ;
2624 }
Original file line number Diff line number Diff line change 77global using FluentValidation . Results ;
88using System . Runtime . CompilerServices ;
99using FluentValidation . Internal ;
10- using HotChocolate . Configuration ;
1110using Microsoft . Extensions . DependencyInjection ;
1211
1312namespace AppAny . HotChocolate . FluentValidation
@@ -35,13 +34,9 @@ public static class ValidationDefaults
3534 public static FieldMiddleware Middleware { get ; } = ValidationMiddlewares . Field ;
3635
3736 /// <summary>
38- /// Default HotChocolate interceptors
37+ /// Default HotChocolate interceptor
3938 /// </summary>
40- public static class Interceptors
41- {
42- public static OnCompleteType OnBeforeCompleteType { get ; } = ValidationInterceptors . OnBeforeCompleteType ;
43- public static OnAfterSchemaCreate OnAfterSchemaCreate { get ; } = ValidationInterceptors . OnAfterSchemaCreate ;
44- }
39+ public static Type Interceptor { get ; } = typeof ( ValidationInterceptor ) ;
4540
4641 /// <summary>
4742 /// Default graphql error extensions keys
Original file line number Diff line number Diff line change 1- using System . Collections . Generic ;
21using System . Linq ;
32using HotChocolate . Configuration ;
43using HotChocolate . Types . Descriptors ;
54using HotChocolate . Types . Descriptors . Definitions ;
65
76namespace AppAny . HotChocolate . FluentValidation
87{
9- internal sealed class ValidationInterceptors
8+ internal sealed class ValidationInterceptor : TypeInterceptor
109 {
11- public static void OnBeforeCompleteType (
10+ public override void OnBeforeCompleteType (
1211 ITypeCompletionContext completionContext ,
13- DefinitionBase ? definition ,
14- IDictionary < string , object ? > contextData )
12+ DefinitionBase ? definition )
1513 {
1614 if ( definition is not ObjectTypeDefinition objectTypeDefinition )
1715 {
@@ -43,7 +41,7 @@ public static void OnBeforeCompleteType(
4341 }
4442 }
4543
46- public static void OnAfterSchemaCreate ( IDescriptorContext descriptorContext , ISchema schema )
44+ public override void OnAfterCreateSchema ( IDescriptorContext descriptorContext , ISchema schema )
4745 {
4846 foreach ( var objectField in schema . Types . OfType < IObjectType > ( ) . SelectMany ( type => type . Fields ) )
4947 {
Original file line number Diff line number Diff line change @@ -26,10 +26,10 @@ public async Task GlobalSetup()
2626 . Argument ( "input" , arg => arg . Type < TestInputType > ( ) . UseFluentValidation ( ) ) ) )
2727 . Services . AddSingleton < IValidator < TestInput > , TestInputValidator > ( ) ) ;
2828
29- fairyBreadValidation = await BenchmarkSetup . CreateRequestExecutor (
30- builder => builder . AddFairyBread ( )
31- . AddMutationType ( new TestMutationType ( field => field . Argument ( "input" , arg => arg . Type < TestInputType > ( ) ) ) )
32- . Services . AddSingleton < TestInputValidator > ( ) . AddSingleton < IValidator < TestInput > , TestInputValidator > ( ) ) ;
29+ // fairyBreadValidation = await BenchmarkSetup.CreateRequestExecutor(
30+ // builder => builder.AddFairyBread()
31+ // .AddMutationType(new TestMutationType(field => field.Argument("input", arg => arg.Type<TestInputType>())))
32+ // .Services.AddSingleton<TestInputValidator>().AddSingleton<IValidator<TestInput>, TestInputValidator>());
3333 }
3434
3535 [ Benchmark ]
Original file line number Diff line number Diff line change @@ -26,10 +26,10 @@ public async Task GlobalSetup()
2626 field . Argument ( "input" , arg => arg . Type < TestInputType > ( ) . UseFluentValidation ( ) ) ) )
2727 . Services . AddSingleton < IValidator < TestInput > , TestInputValidator > ( ) ) ;
2828
29- fairyBreadValidation = await BenchmarkSetup . CreateRequestExecutor (
30- builder => builder . AddFairyBread ( )
31- . AddMutationType ( new TestMutationType ( field => field . Argument ( "input" , arg => arg . Type < TestInputType > ( ) ) ) )
32- . Services . AddSingleton < TestInputValidator > ( ) . AddSingleton < IValidator < TestInput > , TestInputValidator > ( ) ) ;
29+ // fairyBreadValidation = await BenchmarkSetup.CreateRequestExecutor(
30+ // builder => builder.AddFairyBread()
31+ // .AddMutationType(new TestMutationType(field => field.Argument("input", arg => arg.Type<TestInputType>())))
32+ // .Services.AddSingleton<TestInputValidator>().AddSingleton<IValidator<TestInput>, TestInputValidator>());
3333 }
3434
3535 [ Benchmark ]
Original file line number Diff line number Diff line change @@ -26,10 +26,10 @@ public async Task GlobalSetup()
2626 . Type < TestInputType > ( ) . UseFluentValidation ( opt => opt . UseValidator < TestInputValidator > ( ) ) ) ) )
2727 . Services . AddScoped < TestInputValidator > ( ) ) ;
2828
29- fairyBreadValidation = await BenchmarkSetup . CreateRequestExecutor (
30- builder => builder . AddFairyBread ( )
31- . AddMutationType ( new TestMutationType ( field => field . Argument ( "input" , arg => arg . Type < TestInputType > ( ) ) ) )
32- . Services . AddScoped < TestInputValidator > ( ) . AddScoped < IValidator < TestInput > , TestInputValidator > ( ) ) ;
29+ // fairyBreadValidation = await BenchmarkSetup.CreateRequestExecutor(
30+ // builder => builder.AddFairyBread()
31+ // .AddMutationType(new TestMutationType(field => field.Argument("input", arg => arg.Type<TestInputType>())))
32+ // .Services.AddScoped<TestInputValidator>().AddScoped<IValidator<TestInput>, TestInputValidator>());
3333 }
3434
3535 [ Benchmark ]
Original file line number Diff line number Diff line change @@ -26,10 +26,10 @@ public async Task GlobalSetup()
2626 . Type < TestInputType > ( ) . UseFluentValidation ( opt => opt . UseValidator < TestInputValidator > ( ) ) ) ) )
2727 . Services . AddSingleton < TestInputValidator > ( ) ) ;
2828
29- fairyBreadValidation = await BenchmarkSetup . CreateRequestExecutor (
30- builder => builder . AddFairyBread ( )
31- . AddMutationType ( new TestMutationType ( field => field . Argument ( "input" , arg => arg . Type < TestInputType > ( ) ) ) )
32- . Services . AddSingleton < TestInputValidator > ( ) . AddSingleton < IValidator < TestInput > , TestInputValidator > ( ) ) ;
29+ // fairyBreadValidation = await BenchmarkSetup.CreateRequestExecutor(
30+ // builder => builder.AddFairyBread()
31+ // .AddMutationType(new TestMutationType(field => field.Argument("input", arg => arg.Type<TestInputType>())))
32+ // .Services.AddSingleton<TestInputValidator>().AddSingleton<IValidator<TestInput>, TestInputValidator>());
3333 }
3434
3535 [ Benchmark ]
You can’t perform that action at this time.
0 commit comments