Skip to content

Commit

Permalink
MNT Fix broken build
Browse files Browse the repository at this point in the history
  • Loading branch information
Sabina Talipova committed Nov 20, 2023
1 parent 5b40be3 commit b3929c0
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
9 changes: 7 additions & 2 deletions src/Schema/DataObject/Plugin/QuerySort.php
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -111,6 +114,7 @@ public static function sort(array $context): closure
));
}

$normalisedPaths = [];
foreach ($paths as $path => $value) {
$normalised = $schemaContext->mapPath($rootType, $path);
Schema::invariant(
Expand All @@ -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);
};
}

Expand Down
2 changes: 1 addition & 1 deletion tests/Schema/_testFilterAndSort/models.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ SilverStripe\GraphQL\Tests\Fake\DataObjectFake:
filter: true
sort: true
fields:
myField: true
AuthorID: true
myField: true
author:
fields:
firstName: true
Expand Down

0 comments on commit b3929c0

Please sign in to comment.