Merge branch 'v0.10' of https://github.com/webonyx/graphql-php into v0.10

This commit is contained in:
Vladimir Razuvaev 2017-06-27 16:41:31 +07:00
commit b147b528e2
2 changed files with 34 additions and 2 deletions

View File

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

View File

@ -60,6 +60,23 @@ 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
*/
@ -115,3 +132,18 @@ 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;
}
}