diff --git a/src/HotChocolate/Data/test/Data.Sorting.Tests/IntegrationTests.cs b/src/HotChocolate/Data/test/Data.Sorting.Tests/IntegrationTests.cs index e8f3090ddd6..a3f1b961181 100644 --- a/src/HotChocolate/Data/test/Data.Sorting.Tests/IntegrationTests.cs +++ b/src/HotChocolate/Data/test/Data.Sorting.Tests/IntegrationTests.cs @@ -31,6 +31,42 @@ public async Task Sorting_Should_Work_When_UsedWithNonNullDateTime() // assert result.MatchSnapshot(); } + + [Fact] + public async Task Sorting_Should_Work_When_UsedOnAsyncResolver() + { + // arrange + var executor = await new ServiceCollection() + .AddGraphQL() + .AddQueryType( + d => d + .Name(OperationTypeNames.Query) + .Field("foos") + .Type(typeof(List)) + .Resolve(async _ => await Task.FromResult(new List( + [ + new Foo { CreatedUtc = new DateTime(2000, 1, 1, 1, 1, 1) }, + new Foo { CreatedUtc = new DateTime(2010, 1, 1, 1, 1, 1) }, + new Foo { CreatedUtc = new DateTime(2020, 1, 1, 1, 1, 1) } + ]))) + .UseSorting()) + .AddSorting() + .BuildRequestExecutorAsync(); + + const string query = @" + { + foos(order: { createdUtc: DESC }) { + createdUtc + } + } + "; + + // act + var result = await executor.ExecuteAsync(query); + + // assert + result.MatchSnapshot(); + } } public class Query