Skip to content

Commit

Permalink
Added failing test for sorting on an async code-first resolver
Browse files Browse the repository at this point in the history
  • Loading branch information
glen-84 committed Sep 30, 2024
1 parent 7270474 commit 32815a8
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions src/HotChocolate/Data/test/Data.Sorting.Tests/IntegrationTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Foo>))
.Resolve(async _ => await Task.FromResult(new List<Foo>(
[
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
Expand Down

0 comments on commit 32815a8

Please sign in to comment.