mirror of
https://github.com/retailcrm/graphql-php.git
synced 2024-11-29 00:25:17 +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
|
* @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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user