Skip to content

Commit 32815a8

Browse files
committed
Added failing test for sorting on an async code-first resolver
1 parent 7270474 commit 32815a8

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed

src/HotChocolate/Data/test/Data.Sorting.Tests/IntegrationTests.cs

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,42 @@ public async Task Sorting_Should_Work_When_UsedWithNonNullDateTime()
3131
// assert
3232
result.MatchSnapshot();
3333
}
34+
35+
[Fact]
36+
public async Task Sorting_Should_Work_When_UsedOnAsyncResolver()
37+
{
38+
// arrange
39+
var executor = await new ServiceCollection()
40+
.AddGraphQL()
41+
.AddQueryType(
42+
d => d
43+
.Name(OperationTypeNames.Query)
44+
.Field("foos")
45+
.Type(typeof(List<Foo>))
46+
.Resolve(async _ => await Task.FromResult(new List<Foo>(
47+
[
48+
new Foo { CreatedUtc = new DateTime(2000, 1, 1, 1, 1, 1) },
49+
new Foo { CreatedUtc = new DateTime(2010, 1, 1, 1, 1, 1) },
50+
new Foo { CreatedUtc = new DateTime(2020, 1, 1, 1, 1, 1) }
51+
])))
52+
.UseSorting())
53+
.AddSorting()
54+
.BuildRequestExecutorAsync();
55+
56+
const string query = @"
57+
{
58+
foos(order: { createdUtc: DESC }) {
59+
createdUtc
60+
}
61+
}
62+
";
63+
64+
// act
65+
var result = await executor.ExecuteAsync(query);
66+
67+
// assert
68+
result.MatchSnapshot();
69+
}
3470
}
3571

3672
public class Query

0 commit comments

Comments
 (0)