diff --git a/src/HotChocolate/Core/src/Types.CursorPagination/ConnectionType.cs b/src/HotChocolate/Core/src/Types.CursorPagination/ConnectionType.cs index 899d9258a77..cade135dc26 100644 --- a/src/HotChocolate/Core/src/Types.CursorPagination/ConnectionType.cs +++ b/src/HotChocolate/Core/src/Types.CursorPagination/ConnectionType.cs @@ -182,7 +182,7 @@ private static ObjectTypeConfiguration CreateConfiguration( edgesType, pureResolver: GetEdges) { - Flags = CoreFieldFlags.ConnectionEdgesField + Flags = CoreFieldFlags.ParallelExecutable | CoreFieldFlags.ConnectionEdgesField }); if (includeNodesField) @@ -193,7 +193,7 @@ private static ObjectTypeConfiguration CreateConfiguration( ConnectionType_Nodes_Description, pureResolver: GetNodes) { - Flags = CoreFieldFlags.ConnectionNodesField + Flags = CoreFieldFlags.ParallelExecutable | CoreFieldFlags.ConnectionNodesField }); } @@ -206,7 +206,7 @@ private static ObjectTypeConfiguration CreateConfiguration( type: TypeReference.Parse($"{ScalarNames.Int}!"), pureResolver: GetTotalCount) { - Flags = CoreFieldFlags.TotalCount + Flags = CoreFieldFlags.ParallelExecutable | CoreFieldFlags.TotalCount }); } diff --git a/src/HotChocolate/Core/src/Types.OffsetPagination/CollectionSegmentType~1.cs b/src/HotChocolate/Core/src/Types.OffsetPagination/CollectionSegmentType~1.cs index b07eaaacf4b..b111202b118 100644 --- a/src/HotChocolate/Core/src/Types.OffsetPagination/CollectionSegmentType~1.cs +++ b/src/HotChocolate/Core/src/Types.OffsetPagination/CollectionSegmentType~1.cs @@ -99,7 +99,7 @@ private static ObjectTypeConfiguration CreateConfiguration(bool withTotalCount) Names.Items, CollectionSegmentType_Items_Description, pureResolver: GetItems) - { Flags = CoreFieldFlags.CollectionSegmentItemsField }); + { Flags = CoreFieldFlags.ParallelExecutable | CoreFieldFlags.CollectionSegmentItemsField }); if (withTotalCount) { @@ -108,7 +108,7 @@ private static ObjectTypeConfiguration CreateConfiguration(bool withTotalCount) type: TypeReference.Parse($"{ScalarNames.Int}!"), pureResolver: GetTotalCount) { - Flags = CoreFieldFlags.TotalCount + Flags = CoreFieldFlags.ParallelExecutable | CoreFieldFlags.TotalCount }); } diff --git a/src/HotChocolate/Core/test/Types.CursorPagination.Tests/ConnectionTypeTests.cs b/src/HotChocolate/Core/test/Types.CursorPagination.Tests/ConnectionTypeTests.cs new file mode 100644 index 00000000000..1caa4f38cc6 --- /dev/null +++ b/src/HotChocolate/Core/test/Types.CursorPagination.Tests/ConnectionTypeTests.cs @@ -0,0 +1,38 @@ +using HotChocolate.Execution; +using Microsoft.Extensions.DependencyInjection; + +namespace HotChocolate.Types.Pagination; + +public class ConnectionTypeTests +{ + [Fact] + public async Task Fields_Should_BeParallelExecutable_When_GlobalFieldMiddlewareIsRegistered() + { + // arrange + var schema = await new ServiceCollection() + .AddGraphQL() + .AddQueryType() + .UseField(next => next) + .BuildSchemaAsync(cancellationToken: TestContext.Current.CancellationToken); + + // act + var fields = schema.Types.GetType("NamesConnection").Fields + .Where(field => !field.IsIntrospectionField) + .Select(field => $"{field.Name}: {field.IsParallelExecutable}"); + + // assert + string.Join("\n", fields).MatchInlineSnapshot( + """ + pageInfo: True + edges: True + nodes: True + totalCount: True + """); + } + + public class Query + { + [UsePaging(IncludeTotalCount = true)] + public IEnumerable GetNames() => ["a", "b"]; + } +} diff --git a/src/HotChocolate/Core/test/Types.OffsetPagination.Tests/CollectionSegmentTypeTests.cs b/src/HotChocolate/Core/test/Types.OffsetPagination.Tests/CollectionSegmentTypeTests.cs new file mode 100644 index 00000000000..d38e538ef58 --- /dev/null +++ b/src/HotChocolate/Core/test/Types.OffsetPagination.Tests/CollectionSegmentTypeTests.cs @@ -0,0 +1,37 @@ +using HotChocolate.Execution; +using Microsoft.Extensions.DependencyInjection; + +namespace HotChocolate.Types.Pagination; + +public class CollectionSegmentTypeTests +{ + [Fact] + public async Task Fields_Should_BeParallelExecutable_When_GlobalFieldMiddlewareIsRegistered() + { + // arrange + var schema = await new ServiceCollection() + .AddGraphQL() + .AddQueryType() + .UseField(next => next) + .BuildSchemaAsync(cancellationToken: TestContext.Current.CancellationToken); + + // act + var fields = schema.Types.GetType("NamesCollectionSegment").Fields + .Where(field => !field.IsIntrospectionField) + .Select(field => $"{field.Name}: {field.IsParallelExecutable}"); + + // assert + string.Join("\n", fields).MatchInlineSnapshot( + """ + pageInfo: True + items: True + totalCount: True + """); + } + + public class Query + { + [UseOffsetPaging(IncludeTotalCount = true)] + public IEnumerable GetNames() => ["a", "b"]; + } +}