Skip to content

Commit 99dc6f0

Browse files
committed
Minor optimizations for the operation compiler.
1 parent 460f874 commit 99dc6f0

File tree

5 files changed

+22
-11
lines changed

5 files changed

+22
-11
lines changed

src/HotChocolate/Core/src/Execution/Processing/OperationCompiler.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -341,7 +341,8 @@ private void CompleteSelectionSet(CompilerContext context)
341341
isConditional = true;
342342
}
343343

344-
if (fieldType.IsCompositeType())
344+
// Determines if the type is a composite type.
345+
if (fieldType.IsType(TypeKind.Object, TypeKind.Interface, TypeKind.Union))
345346
{
346347
if (selection.SelectionSet is null)
347348
{
@@ -861,4 +862,4 @@ public override bool Equals(object? obj)
861862
public override int GetHashCode()
862863
=> HashCode.Combine(SelectionSet, Path);
863864
}
864-
}
865+
}

src/HotChocolate/Core/src/Execution/Processing/Selection.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ public Selection(
4949
? Flags.Internal
5050
: Flags.None;
5151

52-
if (Type.IsListType())
52+
if (Type.IsType(TypeKind.List))
5353
{
5454
_flags |= Flags.List;
5555
}

src/HotChocolate/Core/src/Types/Types/Extensions/TypeExtensions.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -374,7 +374,7 @@ private static bool IsType(this IType type, TypeKind kind1, TypeKind kind2)
374374
}
375375

376376
[MethodImpl(MethodImplOptions.AggressiveInlining)]
377-
private static bool IsType(this IType type, TypeKind kind1, TypeKind kind2, TypeKind kind3)
377+
internal static bool IsType(this IType type, TypeKind kind1, TypeKind kind2, TypeKind kind3)
378378
{
379379
if (type.Kind == kind1 || type.Kind == kind2 || type.Kind == kind3)
380380
{

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
using HotChocolate.Fusion.Pipeline;
88
using HotChocolate.Fusion.Planning;
99
using HotChocolate.Language;
10+
using HotChocolate.Types.Descriptors;
1011
using Microsoft.Extensions.DependencyInjection.Extensions;
1112
using static HotChocolate.Fusion.ThrowHelper;
1213

@@ -53,6 +54,7 @@ public static FusionGatewayBuilder AddFusionGatewayServer(
5354
.UseField(next => next)
5455
.AddOperationCompilerOptimizer<OperationQueryPlanCompiler>()
5556
.AddOperationCompilerOptimizer<FieldFlagsOptimizer>()
57+
.AddConvention<INamingConventions>(_ => new DefaultNamingConventions())
5658
.Configure(
5759
c =>
5860
{

src/HotChocolate/Fusion/test/Shared/DemoProject.cs

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
using HotChocolate.Fusion.Shared.Products;
77
using HotChocolate.Fusion.Shared.Reviews;
88
using HotChocolate.Fusion.Shared.Shipping;
9+
using HotChocolate.Types.Descriptors;
910
using HotChocolate.Utilities.Introspection;
1011
using Microsoft.AspNetCore.Builder;
1112
using Microsoft.Extensions.DependencyInjection;
@@ -77,7 +78,8 @@ public static async Task<DemoProject> CreateAsync(CancellationToken ct = default
7778
.AddMutationType<ReviewsMutation>()
7879
.AddSubscriptionType<ReviewsSubscription>()
7980
.AddMutationConventions()
80-
.AddGlobalObjectIdentification(),
81+
.AddGlobalObjectIdentification()
82+
.AddConvention<INamingConventions>(_ => new DefaultNamingConventions()),
8183
c => c
8284
.UseWebSockets()
8385
.UseRouting()
@@ -99,7 +101,8 @@ public static async Task<DemoProject> CreateAsync(CancellationToken ct = default
99101
.AddMutationType<Reviews2.ReviewsMutation>()
100102
.AddSubscriptionType<Reviews2.ReviewsSubscription>()
101103
.AddMutationConventions()
102-
.AddGlobalObjectIdentification(),
104+
.AddGlobalObjectIdentification()
105+
.AddConvention<INamingConventions>(_ => new DefaultNamingConventions()),
103106
c => c
104107
.UseWebSockets()
105108
.UseRouting()
@@ -120,7 +123,8 @@ public static async Task<DemoProject> CreateAsync(CancellationToken ct = default
120123
.AddQueryType<AccountQuery>()
121124
.AddMutationType<AccountMutation>()
122125
.AddMutationConventions()
123-
.AddGlobalObjectIdentification(),
126+
.AddGlobalObjectIdentification()
127+
.AddConvention<INamingConventions>(_ => new DefaultNamingConventions()),
124128
c => c
125129
.UseRouting()
126130
.UseEndpoints(endpoints => endpoints.MapGraphQL()));
@@ -138,7 +142,8 @@ public static async Task<DemoProject> CreateAsync(CancellationToken ct = default
138142
.AddSingleton<ProductRepository>()
139143
.AddGraphQLServer()
140144
.AddQueryType<ProductQuery>()
141-
.AddGlobalObjectIdentification(),
145+
.AddGlobalObjectIdentification()
146+
.AddConvention<INamingConventions>(_ => new DefaultNamingConventions()),
142147
c => c
143148
.UseRouting()
144149
.UseEndpoints(endpoints => endpoints.MapGraphQL()));
@@ -155,7 +160,8 @@ public static async Task<DemoProject> CreateAsync(CancellationToken ct = default
155160
.AddRouting()
156161
.AddGraphQLServer()
157162
.AddQueryType<ShippingQuery>()
158-
.ConfigureSchema(b => b.SetContextData(GlobalIdSupportEnabled, 1)),
163+
.ConfigureSchema(b => b.SetContextData(GlobalIdSupportEnabled, 1))
164+
.AddConvention<INamingConventions>(_ => new DefaultNamingConventions()),
159165
c => c
160166
.UseRouting()
161167
.UseEndpoints(endpoints => endpoints.MapGraphQL()));
@@ -174,7 +180,8 @@ public static async Task<DemoProject> CreateAsync(CancellationToken ct = default
174180
.AddQueryType<AppointmentQuery>()
175181
.AddObjectType<Appointments.Patient1>()
176182
.AddObjectType<Patient2>()
177-
.AddGlobalObjectIdentification(),
183+
.AddGlobalObjectIdentification()
184+
.AddConvention<INamingConventions>(_ => new DefaultNamingConventions()),
178185
c => c
179186
.UseRouting()
180187
.UseEndpoints(endpoints => endpoints.MapGraphQL()));
@@ -191,7 +198,8 @@ public static async Task<DemoProject> CreateAsync(CancellationToken ct = default
191198
.AddRouting()
192199
.AddGraphQLServer()
193200
.AddQueryType<Patient1Query>()
194-
.AddGlobalObjectIdentification(),
201+
.AddGlobalObjectIdentification()
202+
.AddConvention<INamingConventions>(_ => new DefaultNamingConventions()),
195203
c => c
196204
.UseRouting()
197205
.UseEndpoints(endpoints => endpoints.MapGraphQL()));

0 commit comments

Comments
 (0)