public function ResolverBuilderTest::testCompositeDefaultValue in GraphQL 8.4
Tests the composite default value resolver.
File
- tests/
src/ Kernel/ ResolverBuilderTest.php, line 372
Class
- ResolverBuilderTest
- Tests that the resolver builder behaves correctly.
Namespace
Drupal\Tests\graphql\KernelCode
public function testCompositeDefaultValue() : void {
$this
->mockResolver('Query', 'tree', [
'name' => 'some tree',
'id' => 5,
]);
$this
->mockResolver('Tree', 'name', $this->builder
->defaultValue($this->builder
->compose($this->builder
->fromValue('baz'), $this->builder
->fromValue(NULL)), $this->builder
->fromValue('bar')));
$this
->mockResolver('Tree', 'uri', $this->builder
->defaultValue($this->builder
->compose($this->builder
->fromValue(TRUE), $this->builder
->fromValue('baz')), $this->builder
->fromValue('bar')));
$query = <<<GQL
query {
tree(id: 1) {
name
uri
}
}
GQL;
$this
->assertResults($query, [], [
'tree' => [
'name' => 'bar',
'uri' => 'baz',
],
]);
}