From d9278777c5948e9ae2c76cf318afe7672181de71 Mon Sep 17 00:00:00 2001 From: Pascal Senn Date: Fri, 16 Oct 2020 00:45:22 +0200 Subject: [PATCH 1/2] feat: add list support to sorting --- .../Expressions/QueryableSortProvider.cs | 3 +- .../SortObjectFieldDescriptorExtensions.cs | 2 + .../Data/Sorting/Visitor/SortVisitorBase`2.cs | 4 +- .../QueryableSortVisitorBooleanTests.cs | 22 ++++++ .../QueryableSortVisitorObjectTests.cs | 67 +++++++++++++++++++ ...Tests.Create_Boolean_OrderBy_List_ASC.snap | 12 ++++ ...ests.Create_Boolean_OrderBy_List_DESC.snap | 12 ++++ ...bjectString_OrderBy_TwoProperties_ASC.snap | 24 +++++++ ...jectString_OrderBy_TwoProperties_DESC.snap | 24 +++++++ .../QueryableSortVisitorBooleanTests.cs | 26 ++++++- .../QueryableSortVisitorObjectTests.cs | 67 ++++++++++++++++++- ...Tests.Create_Boolean_OrderBy_List_ASC.snap | 12 ++++ ...ests.Create_Boolean_OrderBy_List_DESC.snap | 12 ++++ ...bjectString_OrderBy_TwoProperties_ASC.snap | 36 ++++++++++ ...jectString_OrderBy_TwoProperties_DESC.snap | 36 ++++++++++ ...ld_Work_When_ConfiguredWithAttributes.snap | 4 +- ...n_Should_Work_When_ConfiguredWithType.snap | 4 +- ...ExtensionTests.ObjectField_UseSorting.snap | 2 +- ...sts.ObjectField_UseSorting_Descriptor.snap | 2 +- ...tField_UseSorting_Generic_RuntimeType.snap | 2 +- ...ctField_UseSorting_Generic_SchemaType.snap | 2 +- ...jectField_UseSorting_Type_RuntimeType.snap | 2 +- ...bjectField_UseSorting_Type_SchemaType.snap | 2 +- ...buteTests.Create_Schema_With_SortType.snap | 2 +- ..._Schema_With_SortType_With_Fluent_API.snap | 2 +- 25 files changed, 364 insertions(+), 19 deletions(-) create mode 100644 src/HotChocolate/Data/test/Data.Sorting.InMemory.Tests/__snapshots__/QueryableSortVisitorBooleanTests.Create_Boolean_OrderBy_List_ASC.snap create mode 100644 src/HotChocolate/Data/test/Data.Sorting.InMemory.Tests/__snapshots__/QueryableSortVisitorBooleanTests.Create_Boolean_OrderBy_List_DESC.snap create mode 100644 src/HotChocolate/Data/test/Data.Sorting.InMemory.Tests/__snapshots__/QueryableSortVisitorObjectTests.Create_ObjectString_OrderBy_TwoProperties_ASC.snap create mode 100644 src/HotChocolate/Data/test/Data.Sorting.InMemory.Tests/__snapshots__/QueryableSortVisitorObjectTests.Create_ObjectString_OrderBy_TwoProperties_DESC.snap create mode 100644 src/HotChocolate/Data/test/Data.Sorting.SqlLite.Tests/__snapshots__/QueryableSortVisitorBooleanTests.Create_Boolean_OrderBy_List_ASC.snap create mode 100644 src/HotChocolate/Data/test/Data.Sorting.SqlLite.Tests/__snapshots__/QueryableSortVisitorBooleanTests.Create_Boolean_OrderBy_List_DESC.snap create mode 100644 src/HotChocolate/Data/test/Data.Sorting.SqlLite.Tests/__snapshots__/QueryableSortVisitorObjectTests.Create_ObjectString_OrderBy_TwoProperties_ASC.snap create mode 100644 src/HotChocolate/Data/test/Data.Sorting.SqlLite.Tests/__snapshots__/QueryableSortVisitorObjectTests.Create_ObjectString_OrderBy_TwoProperties_DESC.snap diff --git a/src/HotChocolate/Data/src/Data/Sorting/Expressions/QueryableSortProvider.cs b/src/HotChocolate/Data/src/Data/Sorting/Expressions/QueryableSortProvider.cs index a0898b7e440..3560bd63e24 100644 --- a/src/HotChocolate/Data/src/Data/Sorting/Expressions/QueryableSortProvider.cs +++ b/src/HotChocolate/Data/src/Data/Sorting/Expressions/QueryableSortProvider.cs @@ -56,7 +56,8 @@ public override FieldMiddleware CreateExecutor(NameString argumentN source = e.AsQueryable(); } - if (source != null && argument.Type is ISortInputType sortInput) + if (source != null && argument.Type is ListType lt && + lt.ElementType is ISortInputType sortInput) { var visitorContext = new QueryableSortContext( sortInput, diff --git a/src/HotChocolate/Data/src/Data/Sorting/Extensions/SortObjectFieldDescriptorExtensions.cs b/src/HotChocolate/Data/src/Data/Sorting/Extensions/SortObjectFieldDescriptorExtensions.cs index 3b1634fc293..d5598fbdd5d 100644 --- a/src/HotChocolate/Data/src/Data/Sorting/Extensions/SortObjectFieldDescriptorExtensions.cs +++ b/src/HotChocolate/Data/src/Data/Sorting/Extensions/SortObjectFieldDescriptorExtensions.cs @@ -167,6 +167,8 @@ public static class SortObjectFieldDescriptorExtensions throw SortObjectFieldDescriptorExtensions_CannotInfer(); } + argumentType = typeof(ListType<>).MakeGenericType(argumentType); + var argumentDefinition = new ArgumentDefinition { Name = argumentPlaceholder, diff --git a/src/HotChocolate/Data/src/Data/Sorting/Visitor/SortVisitorBase`2.cs b/src/HotChocolate/Data/src/Data/Sorting/Visitor/SortVisitorBase`2.cs index 371666a583d..93fde2752da 100644 --- a/src/HotChocolate/Data/src/Data/Sorting/Visitor/SortVisitorBase`2.cs +++ b/src/HotChocolate/Data/src/Data/Sorting/Visitor/SortVisitorBase`2.cs @@ -87,7 +87,7 @@ protected override ISyntaxVisitorAction Enter(IValueNode node, TContext context) } else { - throw new InvalidOperationException(); + return Continue; } return Break; @@ -104,7 +104,7 @@ protected override ISyntaxVisitorAction Enter(IValueNode node, TContext context) } else { - throw new InvalidOperationException(); + return Continue; } return Break; diff --git a/src/HotChocolate/Data/test/Data.Sorting.InMemory.Tests/QueryableSortVisitorBooleanTests.cs b/src/HotChocolate/Data/test/Data.Sorting.InMemory.Tests/QueryableSortVisitorBooleanTests.cs index 48dad05ec82..395da2f6d8b 100644 --- a/src/HotChocolate/Data/test/Data.Sorting.InMemory.Tests/QueryableSortVisitorBooleanTests.cs +++ b/src/HotChocolate/Data/test/Data.Sorting.InMemory.Tests/QueryableSortVisitorBooleanTests.cs @@ -51,6 +51,28 @@ public async Task Create_Boolean_OrderBy() res2.MatchSnapshot("DESC"); } + [Fact] + public async Task Create_Boolean_OrderBy_List() + { + // arrange + IRequestExecutor tester = _cache.CreateSchema(_fooEntities); + + // act + IExecutionResult res1 = await tester.ExecuteAsync( + QueryRequestBuilder.New() + .SetQuery("{ root(order: [{ bar: ASC}]){ bar}}") + .Create()); + + IExecutionResult res2 = await tester.ExecuteAsync( + QueryRequestBuilder.New() + .SetQuery("{ root(order: [{ bar: DESC}]){ bar}}") + .Create()); + + // assert + res1.MatchSnapshot("ASC"); + res2.MatchSnapshot("DESC"); + } + [Fact] public async Task Create_Boolean_OrderBy_Nullable() { diff --git a/src/HotChocolate/Data/test/Data.Sorting.InMemory.Tests/QueryableSortVisitorObjectTests.cs b/src/HotChocolate/Data/test/Data.Sorting.InMemory.Tests/QueryableSortVisitorObjectTests.cs index aa96c64bbfc..4e6a80926f8 100644 --- a/src/HotChocolate/Data/test/Data.Sorting.InMemory.Tests/QueryableSortVisitorObjectTests.cs +++ b/src/HotChocolate/Data/test/Data.Sorting.InMemory.Tests/QueryableSortVisitorObjectTests.cs @@ -273,6 +273,7 @@ public async Task Create_ObjectNullableEnum_OrderBy() res2.MatchSnapshot("13"); } + [Fact] public async Task Create_ObjectString_OrderBy() { @@ -327,6 +328,7 @@ public async Task Create_ObjectNullableString_OrderBy() res2.MatchSnapshot("13"); } + [Fact] public async Task Create_ObjectBool_OrderBy() { @@ -382,6 +384,71 @@ public async Task Create_ObjectNullableBool_OrderBy() res2.MatchSnapshot("13"); } + [Fact] + public async Task Create_ObjectString_OrderBy_TwoProperties() + { + // arrange + IRequestExecutor tester = _cache.CreateSchema(_barEntities); + + // act + // assert + IExecutionResult res1 = await tester.ExecuteAsync( + QueryRequestBuilder.New() + .SetQuery( + "{ root(order: { foo: { barBool: ASC, barShort: ASC }}) " + + "{ foo{ barBool barShort}}}") + .Create()); + + res1.MatchSnapshot("ASC"); + + IExecutionResult res2 = await tester.ExecuteAsync( + QueryRequestBuilder.New() + .SetQuery( + @" + { + root(order: [ + { foo: { barBool: ASC } }, + { foo: { barShort: ASC } }]) { + foo { + barBool + barShort + } + } + } + ") + .Create()); + + res2.MatchSnapshot("ASC"); + + IExecutionResult res3 = await tester.ExecuteAsync( + QueryRequestBuilder.New() + .SetQuery( + "{ root(order: { foo: { barBool: DESC, barShort: DESC}}) " + + "{ foo{ barBool barShort}}}") + .Create()); + + res3.MatchSnapshot("DESC"); + + IExecutionResult res4 = await tester.ExecuteAsync( + QueryRequestBuilder.New() + .SetQuery( + @" + { + root(order: [ + { foo: { barBool: DESC } }, + { foo: { barShort: DESC } }]) { + foo { + barBool + barShort + } + } + } + ") + .Create()); + + res4.MatchSnapshot("DESC"); + } + public class Foo { public int Id { get; set; } diff --git a/src/HotChocolate/Data/test/Data.Sorting.InMemory.Tests/__snapshots__/QueryableSortVisitorBooleanTests.Create_Boolean_OrderBy_List_ASC.snap b/src/HotChocolate/Data/test/Data.Sorting.InMemory.Tests/__snapshots__/QueryableSortVisitorBooleanTests.Create_Boolean_OrderBy_List_ASC.snap new file mode 100644 index 00000000000..571def30a9a --- /dev/null +++ b/src/HotChocolate/Data/test/Data.Sorting.InMemory.Tests/__snapshots__/QueryableSortVisitorBooleanTests.Create_Boolean_OrderBy_List_ASC.snap @@ -0,0 +1,12 @@ +{ + "data": { + "root": [ + { + "bar": false + }, + { + "bar": true + } + ] + } +} diff --git a/src/HotChocolate/Data/test/Data.Sorting.InMemory.Tests/__snapshots__/QueryableSortVisitorBooleanTests.Create_Boolean_OrderBy_List_DESC.snap b/src/HotChocolate/Data/test/Data.Sorting.InMemory.Tests/__snapshots__/QueryableSortVisitorBooleanTests.Create_Boolean_OrderBy_List_DESC.snap new file mode 100644 index 00000000000..e4537587b54 --- /dev/null +++ b/src/HotChocolate/Data/test/Data.Sorting.InMemory.Tests/__snapshots__/QueryableSortVisitorBooleanTests.Create_Boolean_OrderBy_List_DESC.snap @@ -0,0 +1,12 @@ +{ + "data": { + "root": [ + { + "bar": true + }, + { + "bar": false + } + ] + } +} diff --git a/src/HotChocolate/Data/test/Data.Sorting.InMemory.Tests/__snapshots__/QueryableSortVisitorObjectTests.Create_ObjectString_OrderBy_TwoProperties_ASC.snap b/src/HotChocolate/Data/test/Data.Sorting.InMemory.Tests/__snapshots__/QueryableSortVisitorObjectTests.Create_ObjectString_OrderBy_TwoProperties_ASC.snap new file mode 100644 index 00000000000..38207281c95 --- /dev/null +++ b/src/HotChocolate/Data/test/Data.Sorting.InMemory.Tests/__snapshots__/QueryableSortVisitorObjectTests.Create_ObjectString_OrderBy_TwoProperties_ASC.snap @@ -0,0 +1,24 @@ +{ + "data": { + "root": [ + { + "foo": { + "barBool": false, + "barShort": 13 + } + }, + { + "foo": { + "barBool": true, + "barShort": 12 + } + }, + { + "foo": { + "barBool": true, + "barShort": 14 + } + } + ] + } +} diff --git a/src/HotChocolate/Data/test/Data.Sorting.InMemory.Tests/__snapshots__/QueryableSortVisitorObjectTests.Create_ObjectString_OrderBy_TwoProperties_DESC.snap b/src/HotChocolate/Data/test/Data.Sorting.InMemory.Tests/__snapshots__/QueryableSortVisitorObjectTests.Create_ObjectString_OrderBy_TwoProperties_DESC.snap new file mode 100644 index 00000000000..8f006b215c8 --- /dev/null +++ b/src/HotChocolate/Data/test/Data.Sorting.InMemory.Tests/__snapshots__/QueryableSortVisitorObjectTests.Create_ObjectString_OrderBy_TwoProperties_DESC.snap @@ -0,0 +1,24 @@ +{ + "data": { + "root": [ + { + "foo": { + "barBool": true, + "barShort": 14 + } + }, + { + "foo": { + "barBool": true, + "barShort": 12 + } + }, + { + "foo": { + "barBool": false, + "barShort": 13 + } + } + ] + } +} diff --git a/src/HotChocolate/Data/test/Data.Sorting.SqlLite.Tests/QueryableSortVisitorBooleanTests.cs b/src/HotChocolate/Data/test/Data.Sorting.SqlLite.Tests/QueryableSortVisitorBooleanTests.cs index 0be23fd9b20..f3a57adfd4d 100644 --- a/src/HotChocolate/Data/test/Data.Sorting.SqlLite.Tests/QueryableSortVisitorBooleanTests.cs +++ b/src/HotChocolate/Data/test/Data.Sorting.SqlLite.Tests/QueryableSortVisitorBooleanTests.cs @@ -5,14 +5,12 @@ namespace HotChocolate.Data.Sorting { - public class QueryableSortVisitorBooleanTests : IClassFixture { private static readonly Foo[] _fooEntities = { - new Foo { Bar = true }, - new Foo { Bar = false } + new Foo { Bar = true }, new Foo { Bar = false } }; private static readonly FooNullable[] _fooNullableEntities = @@ -52,6 +50,28 @@ public async Task Create_Boolean_OrderBy() res2.MatchSqlSnapshot("DESC"); } + [Fact] + public async Task Create_Boolean_OrderBy_List() + { + // arrange + IRequestExecutor tester = _cache.CreateSchema(_fooEntities); + + // act + IExecutionResult res1 = await tester.ExecuteAsync( + QueryRequestBuilder.New() + .SetQuery("{ root(order: [{ bar: ASC}]){ bar}}") + .Create()); + + IExecutionResult res2 = await tester.ExecuteAsync( + QueryRequestBuilder.New() + .SetQuery("{ root(order: [{ bar: DESC}]){ bar}}") + .Create()); + + // assert + res1.MatchSnapshot("ASC"); + res2.MatchSnapshot("DESC"); + } + [Fact] public async Task Create_Boolean_OrderBy_Nullable() { diff --git a/src/HotChocolate/Data/test/Data.Sorting.SqlLite.Tests/QueryableSortVisitorObjectTests.cs b/src/HotChocolate/Data/test/Data.Sorting.SqlLite.Tests/QueryableSortVisitorObjectTests.cs index 39eb9967fb3..18d28d6a39e 100644 --- a/src/HotChocolate/Data/test/Data.Sorting.SqlLite.Tests/QueryableSortVisitorObjectTests.cs +++ b/src/HotChocolate/Data/test/Data.Sorting.SqlLite.Tests/QueryableSortVisitorObjectTests.cs @@ -358,7 +358,7 @@ public async Task Create_ObjectNullableBool_OrderBy() .SetQuery( "{ root(order: { foo: { barBool: ASC}}) " + "{ foo{ barBool}}}") - .Create()); + .Create()); IExecutionResult res2 = await tester.ExecuteAsync( QueryRequestBuilder.New() @@ -372,6 +372,71 @@ public async Task Create_ObjectNullableBool_OrderBy() res2.MatchSqlSnapshot("13"); } + [Fact] + public async Task Create_ObjectString_OrderBy_TwoProperties() + { + // arrange + IRequestExecutor tester = _cache.CreateSchema(_barEntities); + + // act + // assert + IExecutionResult res1 = await tester.ExecuteAsync( + QueryRequestBuilder.New() + .SetQuery( + "{ root(order: { foo: { barBool: ASC, barShort: ASC }}) " + + "{ foo{ barBool barShort}}}") + .Create()); + + res1.MatchSnapshot("ASC"); + + IExecutionResult res2 = await tester.ExecuteAsync( + QueryRequestBuilder.New() + .SetQuery( + @" + { + root(order: [ + { foo: { barBool: ASC } }, + { foo: { barShort: ASC } }]) { + foo { + barBool + barShort + } + } + } + ") + .Create()); + + res2.MatchSnapshot("ASC"); + + IExecutionResult res3 = await tester.ExecuteAsync( + QueryRequestBuilder.New() + .SetQuery( + "{ root(order: { foo: { barBool: DESC, barShort: DESC}}) " + + "{ foo{ barBool barShort}}}") + .Create()); + + res3.MatchSnapshot("DESC"); + + IExecutionResult res4 = await tester.ExecuteAsync( + QueryRequestBuilder.New() + .SetQuery( + @" + { + root(order: [ + { foo: { barBool: DESC } }, + { foo: { barShort: DESC } }]) { + foo { + barBool + barShort + } + } + } + ") + .Create()); + + res4.MatchSnapshot("DESC"); + } + public class Foo { public int Id { get; set; } diff --git a/src/HotChocolate/Data/test/Data.Sorting.SqlLite.Tests/__snapshots__/QueryableSortVisitorBooleanTests.Create_Boolean_OrderBy_List_ASC.snap b/src/HotChocolate/Data/test/Data.Sorting.SqlLite.Tests/__snapshots__/QueryableSortVisitorBooleanTests.Create_Boolean_OrderBy_List_ASC.snap new file mode 100644 index 00000000000..571def30a9a --- /dev/null +++ b/src/HotChocolate/Data/test/Data.Sorting.SqlLite.Tests/__snapshots__/QueryableSortVisitorBooleanTests.Create_Boolean_OrderBy_List_ASC.snap @@ -0,0 +1,12 @@ +{ + "data": { + "root": [ + { + "bar": false + }, + { + "bar": true + } + ] + } +} diff --git a/src/HotChocolate/Data/test/Data.Sorting.SqlLite.Tests/__snapshots__/QueryableSortVisitorBooleanTests.Create_Boolean_OrderBy_List_DESC.snap b/src/HotChocolate/Data/test/Data.Sorting.SqlLite.Tests/__snapshots__/QueryableSortVisitorBooleanTests.Create_Boolean_OrderBy_List_DESC.snap new file mode 100644 index 00000000000..e4537587b54 --- /dev/null +++ b/src/HotChocolate/Data/test/Data.Sorting.SqlLite.Tests/__snapshots__/QueryableSortVisitorBooleanTests.Create_Boolean_OrderBy_List_DESC.snap @@ -0,0 +1,12 @@ +{ + "data": { + "root": [ + { + "bar": true + }, + { + "bar": false + } + ] + } +} diff --git a/src/HotChocolate/Data/test/Data.Sorting.SqlLite.Tests/__snapshots__/QueryableSortVisitorObjectTests.Create_ObjectString_OrderBy_TwoProperties_ASC.snap b/src/HotChocolate/Data/test/Data.Sorting.SqlLite.Tests/__snapshots__/QueryableSortVisitorObjectTests.Create_ObjectString_OrderBy_TwoProperties_ASC.snap new file mode 100644 index 00000000000..0f555f794ab --- /dev/null +++ b/src/HotChocolate/Data/test/Data.Sorting.SqlLite.Tests/__snapshots__/QueryableSortVisitorObjectTests.Create_ObjectString_OrderBy_TwoProperties_ASC.snap @@ -0,0 +1,36 @@ +{ + "data": { + "root": [ + { + "foo": { + "barBool": false, + "barShort": 13 + } + }, + { + "foo": { + "barBool": true, + "barShort": 12 + } + }, + { + "foo": { + "barBool": true, + "barShort": 12 + } + }, + { + "foo": { + "barBool": true, + "barShort": 14 + } + }, + { + "foo": { + "barBool": true, + "barShort": 14 + } + } + ] + } +} diff --git a/src/HotChocolate/Data/test/Data.Sorting.SqlLite.Tests/__snapshots__/QueryableSortVisitorObjectTests.Create_ObjectString_OrderBy_TwoProperties_DESC.snap b/src/HotChocolate/Data/test/Data.Sorting.SqlLite.Tests/__snapshots__/QueryableSortVisitorObjectTests.Create_ObjectString_OrderBy_TwoProperties_DESC.snap new file mode 100644 index 00000000000..3ad9164b5fb --- /dev/null +++ b/src/HotChocolate/Data/test/Data.Sorting.SqlLite.Tests/__snapshots__/QueryableSortVisitorObjectTests.Create_ObjectString_OrderBy_TwoProperties_DESC.snap @@ -0,0 +1,36 @@ +{ + "data": { + "root": [ + { + "foo": { + "barBool": true, + "barShort": 14 + } + }, + { + "foo": { + "barBool": true, + "barShort": 14 + } + }, + { + "foo": { + "barBool": true, + "barShort": 12 + } + }, + { + "foo": { + "barBool": true, + "barShort": 12 + } + }, + { + "foo": { + "barBool": false, + "barShort": 13 + } + } + ] + } +} diff --git a/src/HotChocolate/Data/test/Data.Sorting.Tests/Convention/__snapshots__/SortConventionScopeTests.SortConvention_Should_Work_When_ConfiguredWithAttributes.snap b/src/HotChocolate/Data/test/Data.Sorting.Tests/Convention/__snapshots__/SortConventionScopeTests.SortConvention_Should_Work_When_ConfiguredWithAttributes.snap index 86ae878c2e5..10eb3faa136 100644 --- a/src/HotChocolate/Data/test/Data.Sorting.Tests/Convention/__snapshots__/SortConventionScopeTests.SortConvention_Should_Work_When_ConfiguredWithAttributes.snap +++ b/src/HotChocolate/Data/test/Data.Sorting.Tests/Convention/__snapshots__/SortConventionScopeTests.SortConvention_Should_Work_When_ConfiguredWithAttributes.snap @@ -7,8 +7,8 @@ type Foo { } type Query1 { - foos(order: FooSortInput): [Foo!]! - foosBar(order: Bar_FooSortInput): [Foo!]! + foos(order: [FooSortInput]): [Foo!]! + foosBar(order: [Bar_FooSortInput]): [Foo!]! } input Bar_FooSortInput { diff --git a/src/HotChocolate/Data/test/Data.Sorting.Tests/Convention/__snapshots__/SortConventionScopeTests.SortConvention_Should_Work_When_ConfiguredWithType.snap b/src/HotChocolate/Data/test/Data.Sorting.Tests/Convention/__snapshots__/SortConventionScopeTests.SortConvention_Should_Work_When_ConfiguredWithType.snap index b3a261a9e45..e53c778e2af 100644 --- a/src/HotChocolate/Data/test/Data.Sorting.Tests/Convention/__snapshots__/SortConventionScopeTests.SortConvention_Should_Work_When_ConfiguredWithType.snap +++ b/src/HotChocolate/Data/test/Data.Sorting.Tests/Convention/__snapshots__/SortConventionScopeTests.SortConvention_Should_Work_When_ConfiguredWithType.snap @@ -7,8 +7,8 @@ type Foo { } type QueryType { - foos(order: FooSortInput): [Foo] - foosBar(order: Bar_FooSortInput): [Foo] + foos(order: [FooSortInput]): [Foo] + foosBar(order: [Bar_FooSortInput]): [Foo] } input Bar_FooSortInput { diff --git a/src/HotChocolate/Data/test/Data.Sorting.Tests/__snapshots__/ExtensionTests.ObjectField_UseSorting.snap b/src/HotChocolate/Data/test/Data.Sorting.Tests/__snapshots__/ExtensionTests.ObjectField_UseSorting.snap index 335c99bb907..38a6c46f1c7 100644 --- a/src/HotChocolate/Data/test/Data.Sorting.Tests/__snapshots__/ExtensionTests.ObjectField_UseSorting.snap +++ b/src/HotChocolate/Data/test/Data.Sorting.Tests/__snapshots__/ExtensionTests.ObjectField_UseSorting.snap @@ -7,7 +7,7 @@ type Foo { } type Query { - foos(order: FooSortInput): [Foo!]! + foos(order: [FooSortInput]): [Foo!]! } input FooSortInput { diff --git a/src/HotChocolate/Data/test/Data.Sorting.Tests/__snapshots__/ExtensionTests.ObjectField_UseSorting_Descriptor.snap b/src/HotChocolate/Data/test/Data.Sorting.Tests/__snapshots__/ExtensionTests.ObjectField_UseSorting_Descriptor.snap index c2bfa7e716f..6f32739a25e 100644 --- a/src/HotChocolate/Data/test/Data.Sorting.Tests/__snapshots__/ExtensionTests.ObjectField_UseSorting_Descriptor.snap +++ b/src/HotChocolate/Data/test/Data.Sorting.Tests/__snapshots__/ExtensionTests.ObjectField_UseSorting_Descriptor.snap @@ -7,7 +7,7 @@ type Foo { } type Query { - foos(order: foo): [Foo!]! + foos(order: [foo]): [Foo!]! } input foo { diff --git a/src/HotChocolate/Data/test/Data.Sorting.Tests/__snapshots__/ExtensionTests.ObjectField_UseSorting_Generic_RuntimeType.snap b/src/HotChocolate/Data/test/Data.Sorting.Tests/__snapshots__/ExtensionTests.ObjectField_UseSorting_Generic_RuntimeType.snap index a362cf99a3e..b3a0ee6e4a3 100644 --- a/src/HotChocolate/Data/test/Data.Sorting.Tests/__snapshots__/ExtensionTests.ObjectField_UseSorting_Generic_RuntimeType.snap +++ b/src/HotChocolate/Data/test/Data.Sorting.Tests/__snapshots__/ExtensionTests.ObjectField_UseSorting_Generic_RuntimeType.snap @@ -7,7 +7,7 @@ type Foo { } type Query { - foos(order: BarSortInput): [Foo!]! + foos(order: [BarSortInput]): [Foo!]! } input BarSortInput { diff --git a/src/HotChocolate/Data/test/Data.Sorting.Tests/__snapshots__/ExtensionTests.ObjectField_UseSorting_Generic_SchemaType.snap b/src/HotChocolate/Data/test/Data.Sorting.Tests/__snapshots__/ExtensionTests.ObjectField_UseSorting_Generic_SchemaType.snap index a362cf99a3e..b3a0ee6e4a3 100644 --- a/src/HotChocolate/Data/test/Data.Sorting.Tests/__snapshots__/ExtensionTests.ObjectField_UseSorting_Generic_SchemaType.snap +++ b/src/HotChocolate/Data/test/Data.Sorting.Tests/__snapshots__/ExtensionTests.ObjectField_UseSorting_Generic_SchemaType.snap @@ -7,7 +7,7 @@ type Foo { } type Query { - foos(order: BarSortInput): [Foo!]! + foos(order: [BarSortInput]): [Foo!]! } input BarSortInput { diff --git a/src/HotChocolate/Data/test/Data.Sorting.Tests/__snapshots__/ExtensionTests.ObjectField_UseSorting_Type_RuntimeType.snap b/src/HotChocolate/Data/test/Data.Sorting.Tests/__snapshots__/ExtensionTests.ObjectField_UseSorting_Type_RuntimeType.snap index a362cf99a3e..b3a0ee6e4a3 100644 --- a/src/HotChocolate/Data/test/Data.Sorting.Tests/__snapshots__/ExtensionTests.ObjectField_UseSorting_Type_RuntimeType.snap +++ b/src/HotChocolate/Data/test/Data.Sorting.Tests/__snapshots__/ExtensionTests.ObjectField_UseSorting_Type_RuntimeType.snap @@ -7,7 +7,7 @@ type Foo { } type Query { - foos(order: BarSortInput): [Foo!]! + foos(order: [BarSortInput]): [Foo!]! } input BarSortInput { diff --git a/src/HotChocolate/Data/test/Data.Sorting.Tests/__snapshots__/ExtensionTests.ObjectField_UseSorting_Type_SchemaType.snap b/src/HotChocolate/Data/test/Data.Sorting.Tests/__snapshots__/ExtensionTests.ObjectField_UseSorting_Type_SchemaType.snap index a362cf99a3e..b3a0ee6e4a3 100644 --- a/src/HotChocolate/Data/test/Data.Sorting.Tests/__snapshots__/ExtensionTests.ObjectField_UseSorting_Type_SchemaType.snap +++ b/src/HotChocolate/Data/test/Data.Sorting.Tests/__snapshots__/ExtensionTests.ObjectField_UseSorting_Type_SchemaType.snap @@ -7,7 +7,7 @@ type Foo { } type Query { - foos(order: BarSortInput): [Foo!]! + foos(order: [BarSortInput]): [Foo!]! } input BarSortInput { diff --git a/src/HotChocolate/Data/test/Data.Sorting.Tests/__snapshots__/SortAttributeTests.Create_Schema_With_SortType.snap b/src/HotChocolate/Data/test/Data.Sorting.Tests/__snapshots__/SortAttributeTests.Create_Schema_With_SortType.snap index 09b07d4b916..b92f6789136 100644 --- a/src/HotChocolate/Data/test/Data.Sorting.Tests/__snapshots__/SortAttributeTests.Create_Schema_With_SortType.snap +++ b/src/HotChocolate/Data/test/Data.Sorting.Tests/__snapshots__/SortAttributeTests.Create_Schema_With_SortType.snap @@ -9,7 +9,7 @@ type Foo { } type Query1 { - foos(order: FooSortInput): [Foo!]! + foos(order: [FooSortInput]): [Foo!]! } input FooSortInput { diff --git a/src/HotChocolate/Data/test/Data.Sorting.Tests/__snapshots__/SortAttributeTests.Create_Schema_With_SortType_With_Fluent_API.snap b/src/HotChocolate/Data/test/Data.Sorting.Tests/__snapshots__/SortAttributeTests.Create_Schema_With_SortType_With_Fluent_API.snap index 10d0a678b9d..a8c94592005 100644 --- a/src/HotChocolate/Data/test/Data.Sorting.Tests/__snapshots__/SortAttributeTests.Create_Schema_With_SortType_With_Fluent_API.snap +++ b/src/HotChocolate/Data/test/Data.Sorting.Tests/__snapshots__/SortAttributeTests.Create_Schema_With_SortType_With_Fluent_API.snap @@ -9,7 +9,7 @@ type Foo { } type Query2 { - foos(order: FooSortInput): [Foo!]! + foos(order: [FooSortInput]): [Foo!]! } input FooSortInput { From ce3568d1deebf3129a3869b45f2b483bab727f83 Mon Sep 17 00:00:00 2001 From: Pascal Senn Date: Fri, 16 Oct 2020 00:49:48 +0200 Subject: [PATCH 2/2] fix format --- .../Data/src/Data/Sorting/Expressions/QueryableSortProvider.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/HotChocolate/Data/src/Data/Sorting/Expressions/QueryableSortProvider.cs b/src/HotChocolate/Data/src/Data/Sorting/Expressions/QueryableSortProvider.cs index 3560bd63e24..6280f8a3ef9 100644 --- a/src/HotChocolate/Data/src/Data/Sorting/Expressions/QueryableSortProvider.cs +++ b/src/HotChocolate/Data/src/Data/Sorting/Expressions/QueryableSortProvider.cs @@ -56,7 +56,8 @@ public override FieldMiddleware CreateExecutor(NameString argumentN source = e.AsQueryable(); } - if (source != null && argument.Type is ListType lt && + if (source != null && + argument.Type is ListType lt && lt.ElementType is ISortInputType sortInput) { var visitorContext = new QueryableSortContext(