Skip to content

Commit

Permalink
Throw if versioned used on nested query
Browse files Browse the repository at this point in the history
  • Loading branch information
Aaron Carlino committed Sep 17, 2020
1 parent e6fe184 commit 7e3ebfb
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/GraphQL/Resolvers/VersionFilters.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
namespace SilverStripe\GraphQL\Resolvers;

use SilverStripe\ORM\DataList;
use SilverStripe\ORM\RelationList;
use SilverStripe\ORM\UnsavedRelationList;
use SilverStripe\Versioned\Versioned;
use InvalidArgumentException;
use DateTime;
Expand Down Expand Up @@ -61,6 +63,12 @@ public function applyToReadingState(array $versioningArgs)
*/
public function applyToList(DataList $list, array $versioningArgs): DataList
{
if ($list instanceof RelationList) {
throw new InvalidArgumentException(sprintf(
'Version filtering cannot be applied to instances of %s. Are you using the plugin on a nested query?',
get_class($list)
));
}
if (!isset($versioningArgs['mode'])) {
$list;
}
Expand Down

0 comments on commit 7e3ebfb

Please sign in to comment.