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
2 changes: 1 addition & 1 deletion src/HotChocolate/Data/src/Data/Sorting/Fields/SortField.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ protected override void OnCompleteField(

if (Member?.DeclaringType is not null)
{
RuntimeType = context.TypeInspector.GetReturnType(Member);
RuntimeType = context.TypeInspector.GetReturnType(Member, ignoreAttributes: true);
}
}
}
Expand Down
55 changes: 55 additions & 0 deletions src/HotChocolate/Data/test/Data.Sorting.Tests/IntegrationTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using HotChocolate.Execution;
using HotChocolate.Tests;
using HotChocolate.Types;
using Microsoft.Extensions.DependencyInjection;
using Xunit;

namespace HotChocolate.Data.Tests;

public class IntegrationTests
{
[Fact]
public async Task Sorting_Should_Work_When_UsedWithNonNullDateTime()
{
// arrange
IRequestExecutor executor = await new ServiceCollection()
.AddGraphQL()
.AddQueryType<Query>()
.AddSorting()
.BuildRequestExecutorAsync();

const string query = @"
{
foos(order: { createdUtc: DESC }) {
createdUtc
}
}
";

// act
IExecutionResult result = await executor.ExecuteAsync(query);

// assert
result.MatchSnapshot();
}
}

public class Query
{
[UseSorting]
public IEnumerable<Foo> Foos() => new[]
{
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) }
};
}

public class Foo
{
[GraphQLType(typeof(NonNullType<DateType>))]
public DateTime CreatedUtc { get; set; }
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"data": {
"foos": [
{
"createdUtc": "2020-01-01"
},
{
"createdUtc": "2010-01-01"
},
{
"createdUtc": "2000-01-01"
}
]
}
}