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 #973

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
4 changes: 2 additions & 2 deletions tests/GraphQL/DuplicateElementMutationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
use DNADesign\Elemental\GraphQL\DuplicateElementMutation;
use DNADesign\Elemental\Models\BaseElement;
use DNADesign\Elemental\Models\ElementalArea;
use GraphQL\Type\Definition\ResolveInfo;
use DNADesign\Elemental\Tests\GraphQL\FakeResolveInfo;
use InvalidArgumentException;
use SilverStripe\Dev\SapphireTest;
use SilverStripe\Security\Security;
Expand Down Expand Up @@ -62,7 +62,7 @@ public function canCreate($member = null, $context = [])
$object = null;
$args = ['id' => $element->ID];
$context = ['currentUser' => Security::getCurrentUser()];
$resolveInfo = new ResolveInfo([]);
$resolveInfo = new FakeResolveInfo();

$this->expectException(InvalidArgumentException::class);
$this->expectExceptionMessageRegExp("#insufficient permission to {$operation}#");
Expand Down
21 changes: 20 additions & 1 deletion tests/GraphQL/FakeResolveInfo.php
Original file line number Diff line number Diff line change
@@ -1,13 +1,32 @@
<?php


namespace DNADesign\Elemental\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,
[]
);
}
}
4 changes: 2 additions & 2 deletions tests/GraphQL/Legacy/AddElementToAreaMutationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

use DNADesign\Elemental\GraphQL\AddElementToAreaMutation;
use DNADesign\Elemental\Models\ElementalArea;
use DNADesign\Elemental\Tests\GraphQL\FakeResolveInfo;
use DNADesign\Elemental\Tests\Src\TestElement;
use GraphQL\Type\Definition\ResolveInfo;
use InvalidArgumentException;
use SilverStripe\Dev\SapphireTest;
use SilverStripe\GraphQL\Schema\Schema;
Expand Down Expand Up @@ -81,7 +81,7 @@ protected function runMutation($className, $elementalAreaID, $afterElementId = n
{
$mutation = new AddElementToAreaMutation();
$context = ['currentUser' => Security::getCurrentUser()];
$resolveInfo = new ResolveInfo([]);
$resolveInfo = new FakeResolveInfo();

$args = [
'className' => $className,
Expand Down
4 changes: 2 additions & 2 deletions tests/GraphQL/Legacy/SortBlockMutationCreatorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
namespace DNADesign\Elemental\Tests\Legacy\GraphQL;

use DNADesign\Elemental\GraphQL\SortBlockMutationCreator;
use DNADesign\Elemental\Tests\GraphQL\FakeResolveInfo;
use DNADesign\Elemental\Tests\Src\TestElement;
use GraphQL\Type\Definition\ResolveInfo;
use SilverStripe\Dev\SapphireTest;
use SilverStripe\GraphQL\Schema\Schema;
use SilverStripe\Security\Security;
Expand Down Expand Up @@ -56,7 +56,7 @@ protected function runMutation($id, $afterBlockId)

$mutation = new SortBlockMutationCreator();
$context = ['currentUser' => $member];
$resolveInfo = new ResolveInfo([]);
$resolveInfo = new FakeResolveInfo();

$mutation->resolve(null, [
'id' => $id,
Expand Down