Skip to content

Commit

Permalink
MNT Compatibility with webonyx/graphql-php v14
Browse files Browse the repository at this point in the history
  • Loading branch information
emteknetnz committed Apr 12, 2022
1 parent d3c58c7 commit 214d81a
Show file tree
Hide file tree
Showing 9 changed files with 36 additions and 15 deletions.
2 changes: 1 addition & 1 deletion tests/php/GraphQL/CreateFolderMutationCreatorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
use SilverStripe\Assets\File;
use SilverStripe\Assets\Folder;
use SilverStripe\Dev\SapphireTest;
use GraphQL\Type\Definition\ResolveInfo;
use SilverStripe\GraphQL\Schema\Schema;
use SilverStripe\Versioned\Tests\GraphQL\Fake\Fake;
use SilverStripe\AssetAdmin\Tests\GraphQL\FakeResolveInfo;

class CreateFolderMutationCreatorTest extends SapphireTest
{
Expand Down
21 changes: 20 additions & 1 deletion tests/php/GraphQL/FakeResolveInfo.php
Original file line number Diff line number Diff line change
@@ -1,13 +1,32 @@
<?php


namespace SilverStripe\AssetAdmin\Tests\GraphQL;

use GraphQL\Type\Definition\FieldDefinition;
use GraphQL\Type\Definition\ResolveInfo;
use GraphQL\Type\Definition\ObjectType;
use GraphQL\Type\Definition\Type;
use GraphQL\Type\Schema;

class FakeResolveInfo extends ResolveInfo
{
public function __construct()
{
// webonyx/graphql-php v0.12
if (!property_exists(__CLASS__, 'fieldDefinition')) {
return;
}
// webonyx/graphql-php v14
parent::__construct(
FieldDefinition::create(['name' => 'fake', 'type' => Type::string()]),
[],
new ObjectType(['name' => 'fake']),
[],
new Schema([]),
[],
'',
null,
[]
);
}
}
2 changes: 1 addition & 1 deletion tests/php/GraphQL/FolderTypeCreatorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

namespace SilverStripe\AssetAdmin\Tests\GraphQL;

use GraphQL\Type\Definition\ResolveInfo;
use SilverStripe\AssetAdmin\GraphQL\FolderTypeCreator;
use SilverStripe\AssetAdmin\GraphQL\Resolvers\FolderTypeResolver;
use SilverStripe\AssetAdmin\Tests\GraphQL\FakeResolveInfo;
use SilverStripe\Assets\File;
use SilverStripe\Assets\Folder;
use SilverStripe\Dev\SapphireTest;
Expand Down
5 changes: 3 additions & 2 deletions tests/php/GraphQL/Legacy/CreateFolderMutationCreatorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use SilverStripe\AssetAdmin\Tests\Controller\AssetAdminTest\FileExtension;
use SilverStripe\AssetAdmin\Tests\Controller\AssetAdminTest\FolderExtension;
use SilverStripe\AssetAdmin\Tests\GraphQL\FakeResolveInfo;
use SilverStripe\Assets\File;
use SilverStripe\Assets\Folder;
use SilverStripe\Dev\SapphireTest;
Expand Down Expand Up @@ -46,7 +47,7 @@ public function testItCreatesFolder()
]
];
$creator = new CreateFolderMutationCreator();
$newFolder = $creator->resolve(null, $args, null, new ResolveInfo([]));
$newFolder = $creator->resolve(null, $args, null, new FakeResolveInfo());
$this->assertNotNull($newFolder);
$this->assertEquals($folder1->ID, $newFolder->ParentID);
$this->assertEquals('testItCreatesFolder', $newFolder->Name);
Expand All @@ -65,6 +66,6 @@ public function testItRestrictsCreateFolderByCanCreate()
]
];
$creator = new CreateFolderMutationCreator();
$creator->resolve(null, $args, null, new ResolveInfo([]));
$creator->resolve(null, $args, null, new FakeResolveInfo());
}
}
5 changes: 3 additions & 2 deletions tests/php/GraphQL/Legacy/FolderTypeCreatorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace SilverStripe\AssetAdmin\Tests\Legacy\GraphQL;

use GraphQL\Type\Definition\ResolveInfo;
use SilverStripe\AssetAdmin\Tests\GraphQL\FakeResolveInfo;
use SilverStripe\AssetAdmin\GraphQL\FolderTypeCreator;
use SilverStripe\Assets\File;
use SilverStripe\Assets\Folder;
Expand Down Expand Up @@ -130,7 +131,7 @@ public function testItShowsParents()
$folder1_1_1,
[],
$this->getContext(),
new ResolveInfo([])
new FakeResolveInfo()
);
$this->assertEquals(
[
Expand Down Expand Up @@ -165,7 +166,7 @@ protected function resolveChildrenConnection($object, $args, $context = null)
$object,
$args,
$context,
new ResolveInfo([]),
new FakeResolveInfo(),
$creator->getChildrenConnection()
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
use SilverStripe\AssetAdmin\GraphQL\ReadDescendantFileCountsQueryCreator;
use SilverStripe\AssetAdmin\Tests\Controller\AssetAdminTest\FileExtension;
use SilverStripe\AssetAdmin\Tests\Controller\AssetAdminTest\FolderExtension;
use SilverStripe\AssetAdmin\Tests\GraphQL\FakeResolveInfo;
use SilverStripe\Assets\File;
use SilverStripe\Assets\Folder;
use SilverStripe\Dev\SapphireTest;
use GraphQL\Type\Definition\ResolveInfo;
use SilverStripe\GraphQL\Manager;
use Silverstripe\Assets\Dev\TestAssetStore;
use SilverStripe\GraphQL\Schema\Schema;
Expand Down Expand Up @@ -78,7 +78,7 @@ protected function getResultsForSearch($args, $context = null)
{
$context = $context ? $context : ['currentUser' => null];
$creator = new ReadDescendantFileCountsQueryCreator(new Manager());
return $creator->resolve(null, $args, $context, new ResolveInfo([]));
return $creator->resolve(null, $args, $context, new FakeResolveInfo());
}

/**
Expand Down
4 changes: 2 additions & 2 deletions tests/php/GraphQL/Legacy/ReadFileQueryCreatorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
use SilverStripe\AssetAdmin\GraphQL\ReadFileQueryCreator;
use SilverStripe\AssetAdmin\Tests\Controller\AssetAdminTest\FileExtension;
use SilverStripe\AssetAdmin\Tests\Controller\AssetAdminTest\FolderExtension;
use SilverStripe\AssetAdmin\Tests\GraphQL\FakeResolveInfo;
use SilverStripe\Assets\File;
use SilverStripe\Assets\Folder;
use SilverStripe\Dev\SapphireTest;
use GraphQL\Type\Definition\ResolveInfo;
use SilverStripe\GraphQL\Manager;
use Silverstripe\Assets\Dev\TestAssetStore;
use SilverStripe\GraphQL\Schema\Schema;
Expand Down Expand Up @@ -90,6 +90,6 @@ protected function getResultsForSearch($args, $context = null)
{
$context = $context ? $context : ['currentUser' => null];
$creator = new ReadFileQueryCreator(new Manager());
return $creator->resolveConnection(null, $args, $context, new ResolveInfo([]));
return $creator->resolveConnection(null, $args, $context, new FakeResolveInfo());
}
}
4 changes: 2 additions & 2 deletions tests/php/GraphQL/Legacy/ReadFileUsageQueryCreatorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@

namespace SilverStripe\AssetAdmin\Tests\Legacy\GraphQL;

use SilverStripe\AssetAdmin\Tests\GraphQL\FakeResolveInfo;
use SilverStripe\AssetAdmin\GraphQL\ReadFileQueryCreator;
use SilverStripe\AssetAdmin\GraphQL\ReadFileUsageQueryCreator;
use SilverStripe\AssetAdmin\Tests\Controller\AssetAdminTest\FileExtension;
use SilverStripe\AssetAdmin\Tests\Controller\AssetAdminTest\FolderExtension;
use SilverStripe\Assets\File;
use SilverStripe\Assets\Folder;
use SilverStripe\Dev\SapphireTest;
use GraphQL\Type\Definition\ResolveInfo;
use SilverStripe\GraphQL\Manager;
use Silverstripe\Assets\Dev\TestAssetStore;
use SilverStripe\GraphQL\Schema\Schema;
Expand Down Expand Up @@ -84,7 +84,7 @@ protected function getResultsForSearch($args, $context = null)
{
$context = $context ? $context : ['currentUser' => null];
$creator = new ReadFileUsageQueryCreator(new Manager());
return $creator->resolve(null, $args, $context, new ResolveInfo([]));
return $creator->resolve(null, $args, $context, new FakeResolveInfo());
}

/**
Expand Down
4 changes: 2 additions & 2 deletions tests/php/GraphQL/Legacy/UnpublishFileMutationCreatorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

namespace SilverStripe\AssetAdmin\Tests\Legacy\GraphQL;

use GraphQL\Type\Definition\ResolveInfo;
use SilverStripe\AssetAdmin\GraphQL\Notice;
use SilverStripe\AssetAdmin\GraphQL\UnpublishFileMutationCreator;
use SilverStripe\AssetAdmin\Tests\GraphQL\FakeResolveInfo;
use SilverStripe\AssetAdmin\Tests\GraphQL\UnpublishFileMutationCreatorTest\FileOwner;
use SilverStripe\Assets\File;
use SilverStripe\Dev\SapphireTest;
Expand Down Expand Up @@ -36,7 +36,7 @@ public function testUnpublishWithOwners()
$member = Security::getCurrentUser();
$mutation = new UnpublishFileMutationCreator();
$context = ['currentUser' => $member];
$resolveInfo = new ResolveInfo([]);
$resolveInfo = new FakeResolveInfo();

/** @var File $file */
$file = $this->objFromFixture(File::class, 'file1');
Expand Down

0 comments on commit 214d81a

Please sign in to comment.