mirror of
https://github.com/retailcrm/graphql-php.git
synced 2024-11-25 06:16:05 +03:00
Merge branch 'v0.10' of https://github.com/webonyx/graphql-php into v0.10
This commit is contained in:
commit
b147b528e2
@ -913,7 +913,7 @@ class Executor
|
||||
}
|
||||
}
|
||||
|
||||
return $property instanceof \Closure ? $property($source, $args, $context) : $property;
|
||||
return is_callable($property) ? $property($source, $args, $context) : $property;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -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
|
||||
*/
|
||||
@ -114,4 +131,19 @@ class ResolveTest extends \PHPUnit_Framework_TestCase
|
||||
GraphQL::execute($schema, '{ test(aInt: -123, aStr: "String!") }', 'Source!')
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class ResolveTestCallableFixture
|
||||
{
|
||||
private $value;
|
||||
|
||||
public function __construct($value)
|
||||
{
|
||||
$this->value = $value;
|
||||
}
|
||||
|
||||
public function __invoke($root, $args, $context)
|
||||
{
|
||||
return $this->value;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user