Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ private static ObjectTypeConfiguration CreateConfiguration(
edgesType,
pureResolver: GetEdges)
{
Flags = CoreFieldFlags.ConnectionEdgesField
Flags = CoreFieldFlags.ParallelExecutable | CoreFieldFlags.ConnectionEdgesField
});

if (includeNodesField)
Expand All @@ -193,7 +193,7 @@ private static ObjectTypeConfiguration CreateConfiguration(
ConnectionType_Nodes_Description,
pureResolver: GetNodes)
{
Flags = CoreFieldFlags.ConnectionNodesField
Flags = CoreFieldFlags.ParallelExecutable | CoreFieldFlags.ConnectionNodesField
});
}

Expand All @@ -206,7 +206,7 @@ private static ObjectTypeConfiguration CreateConfiguration(
type: TypeReference.Parse($"{ScalarNames.Int}!"),
pureResolver: GetTotalCount)
{
Flags = CoreFieldFlags.TotalCount
Flags = CoreFieldFlags.ParallelExecutable | CoreFieldFlags.TotalCount
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand All @@ -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
});
}

Expand Down
Original file line number Diff line number Diff line change
@@ -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<Query>()
.UseField(next => next)
.BuildSchemaAsync(cancellationToken: TestContext.Current.CancellationToken);

// act
var fields = schema.Types.GetType<ObjectType>("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<string> GetNames() => ["a", "b"];
}
}
Original file line number Diff line number Diff line change
@@ -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<Query>()
.UseField(next => next)
.BuildSchemaAsync(cancellationToken: TestContext.Current.CancellationToken);

// act
var fields = schema.Types.GetType<ObjectType>("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<string> GetNames() => ["a", "b"];
}
}
Loading