From b3929c082e5d4fd1e3e0ff032d66c80f352eceba Mon Sep 17 00:00:00 2001 From: Sabina Talipova Date: Tue, 14 Nov 2023 20:14:26 +1300 Subject: [PATCH] MNT Fix broken build --- src/Schema/DataObject/Plugin/QuerySort.php | 9 +++++++-- tests/Schema/_testFilterAndSort/models.yml | 2 +- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/Schema/DataObject/Plugin/QuerySort.php b/src/Schema/DataObject/Plugin/QuerySort.php index 1647bc34..791ea1cc 100644 --- a/src/Schema/DataObject/Plugin/QuerySort.php +++ b/src/Schema/DataObject/Plugin/QuerySort.php @@ -102,6 +102,9 @@ public static function sort(array $context): closure } $filterArgs = $args[$fieldName] ?? []; $paths = NestedInputBuilder::buildPathsFromArgs($filterArgs); + if (empty($paths)) { + return $list; + } $schemaContext = SchemaConfigProvider::get($context); if (!$schemaContext) { throw new Exception(sprintf( @@ -111,6 +114,7 @@ public static function sort(array $context): closure )); } + $normalisedPaths = []; foreach ($paths as $path => $value) { $normalised = $schemaContext->mapPath($rootType, $path); Schema::invariant( @@ -120,10 +124,11 @@ public static function sort(array $context): closure $path, $rootType ); - $list = $list->sort($normalised, $value); + + $normalisedPaths[$normalised] = $value; } - return $list; + return $list->sort($normalisedPaths); }; } diff --git a/tests/Schema/_testFilterAndSort/models.yml b/tests/Schema/_testFilterAndSort/models.yml index 17343286..ccebcf47 100644 --- a/tests/Schema/_testFilterAndSort/models.yml +++ b/tests/Schema/_testFilterAndSort/models.yml @@ -5,8 +5,8 @@ SilverStripe\GraphQL\Tests\Fake\DataObjectFake: filter: true sort: true fields: - myField: true AuthorID: true + myField: true author: fields: firstName: true