Reverted #116 (now Executor::defaultFieldResolver checks for instanceof Closure vs is_callable again)

This commit is contained in:
Vladimir Razuvaev 2017-07-08 14:56:15 +07:00
parent 3beeb06340
commit 463d995d95
2 changed files with 3 additions and 35 deletions

View File

@ -965,7 +965,7 @@ class Executor
}
}
return is_callable($property) ? $property($source, $args, $context, $info) : $property;
return $property instanceof \Closure ? $property($source, $args, $context, $info) : $property;
}
/**

View File

@ -44,13 +44,13 @@ class ResolveTest extends \PHPUnit_Framework_TestCase
/**
* @it default function calls methods
*/
public function testDefaultFunctionCallsMethods()
public function testDefaultFunctionCallsClosures()
{
$schema = $this->buildSchema(['type' => Type::string()]);
$_secret = 'secretValue' . uniqid();
$source = [
'test' => function () use ($_secret) {
'test' => function() use ($_secret) {
return $_secret;
}
];
@ -60,23 +60,6 @@ class ResolveTest extends \PHPUnit_Framework_TestCase
);
}
/**
* @it default function calls callables
*/
public function testDefaultFunctionCallsCallables()
{
$schema = $this->buildSchema(['type' => Type::string()]);
$_secret = 'secretValue' . uniqid();
$source = [
'test' => new ResolveTestCallableFixture($_secret)
];
$this->assertEquals(
['data' => ['test' => $_secret]],
GraphQL::execute($schema, '{ test }', $source)
);
}
/**
* @it default function passes args and context
*/
@ -132,18 +115,3 @@ class ResolveTest extends \PHPUnit_Framework_TestCase
);
}
}
class ResolveTestCallableFixture
{
private $value;
public function __construct($value)
{
$this->value = $value;
}
public function __invoke($root, $args, $context)
{
return $this->value;
}
}