public function ResolverBuilderTest::testDeferredCond in GraphQL 8.4
@covers ::cond
File
- tests/
src/ Kernel/ ResolverBuilderTest.php, line 271
Class
- ResolverBuilderTest
- Tests that the resolver builder behaves correctly.
Namespace
Drupal\Tests\graphql\KernelCode
public function testDeferredCond() : void {
$this
->mockResolver('Query', 'tree', $this->builder
->fromValue([
'name' => 'some tree',
'id' => 5,
]));
$this
->mockResolver('Tree', 'name', $this->builder
->cond([
[
$this->builder
->fromValue(FALSE),
$this->builder
->fromValue('This should not be in the result.'),
],
[
function () {
return new Deferred(function () {
return TRUE;
});
},
$this->builder
->fromValue('But this should.'),
],
[
$this->builder
->fromValue(TRUE),
$this->builder
->fromValue('And this not, event though its true.'),
],
]));
$query = <<<GQL
query {
tree {
name
}
}
GQL;
$this
->assertResults($query, [], [
'tree' => [
'name' => 'But this should.',
],
]);
}