mirror of
https://github.com/retailcrm/graphql-php.git
synced 2025-02-11 10:09:24 +03:00
Reverted #116 (now Executor::defaultFieldResolver checks for instanceof Closure vs is_callable again)
This commit is contained in:
parent
3beeb06340
commit
463d995d95
@ -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;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -44,13 +44,13 @@ class ResolveTest extends \PHPUnit_Framework_TestCase
|
|||||||
/**
|
/**
|
||||||
* @it default function calls methods
|
* @it default function calls methods
|
||||||
*/
|
*/
|
||||||
public function testDefaultFunctionCallsMethods()
|
public function testDefaultFunctionCallsClosures()
|
||||||
{
|
{
|
||||||
$schema = $this->buildSchema(['type' => Type::string()]);
|
$schema = $this->buildSchema(['type' => Type::string()]);
|
||||||
$_secret = 'secretValue' . uniqid();
|
$_secret = 'secretValue' . uniqid();
|
||||||
|
|
||||||
$source = [
|
$source = [
|
||||||
'test' => function () use ($_secret) {
|
'test' => function() use ($_secret) {
|
||||||
return $_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
|
* @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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user