Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added failing test for sorting on an async code-first resolver #7535

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
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
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
Loading