Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MNT Compatibility with webonyx/graphql-php v14 #1266

Merged
merged 1 commit into from
Apr 13, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
6 changes: 3 additions & 3 deletions tests/php/GraphQL/Legacy/CreateFolderMutationCreatorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@

use SilverStripe\AssetAdmin\Tests\Controller\AssetAdminTest\FileExtension;
use SilverStripe\AssetAdmin\Tests\Controller\AssetAdminTest\FolderExtension;
use SilverStripe\AssetAdmin\Tests\GraphQL\FakeResolveInfo;
GuySartorelli marked this conversation as resolved.
Show resolved Hide resolved
use SilverStripe\Assets\File;
use SilverStripe\Assets\Folder;
use SilverStripe\Dev\SapphireTest;
use GraphQL\Type\Definition\ResolveInfo;
use SilverStripe\AssetAdmin\GraphQL\CreateFolderMutationCreator;
use SilverStripe\GraphQL\Schema\Schema;

Expand Down Expand Up @@ -46,7 +46,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 +65,6 @@ public function testItRestrictsCreateFolderByCanCreate()
]
];
$creator = new CreateFolderMutationCreator();
$creator->resolve(null, $args, null, new ResolveInfo([]));
$creator->resolve(null, $args, null, new FakeResolveInfo());
}
}
6 changes: 3 additions & 3 deletions tests/php/GraphQL/Legacy/FolderTypeCreatorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,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 +130,7 @@ public function testItShowsParents()
$folder1_1_1,
[],
$this->getContext(),
new ResolveInfo([])
new FakeResolveInfo()
);
$this->assertEquals(
[
Expand Down Expand Up @@ -165,7 +165,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;
GuySartorelli marked this conversation as resolved.
Show resolved Hide resolved
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;
GuySartorelli marked this conversation as resolved.
Show resolved Hide resolved
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;
GuySartorelli marked this conversation as resolved.
Show resolved Hide resolved
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