Loading src/GraphQL/Resolver/Condition.php +2 −1 Original line number Diff line number Diff line Loading @@ -37,7 +37,8 @@ class Condition implements ResolverInterface { */ public function resolve($value, $args, ResolveContext $context, ResolveInfo $info, FieldContext $field) { $branches = $this->branches; while ([$condition, $resolver] = array_pad(array_shift($branches), 2, NULL)) { while ($branch = array_shift($branches)) { [$condition, $resolver] = array_pad($branch, 2, NULL); if ($condition instanceof ResolverInterface) { if (($condition = $condition->resolve($value, $args, $context, $info, $field)) === NULL) { // Bail out early if a resolver returns NULL. Loading tests/src/Kernel/ResolverBuilderTest.php +20 −0 Original line number Diff line number Diff line Loading @@ -231,6 +231,26 @@ GQL; $this->assertResults($query, [], ['tree' => ['context' => ['myContext' => 'my context value']]]); } /** * @covers ::cond */ public function testSingleCond(): void { $this->mockResolver('Query', 'me', $this->builder->cond([ [ $this->builder->fromValue(FALSE), $this->builder->fromValue('This should resolve into null.'), ], ])); $query = <<<GQL query { me } GQL; $this->assertResults($query, [], ['me' => NULL]); } /** * @covers ::cond */ Loading Loading
src/GraphQL/Resolver/Condition.php +2 −1 Original line number Diff line number Diff line Loading @@ -37,7 +37,8 @@ class Condition implements ResolverInterface { */ public function resolve($value, $args, ResolveContext $context, ResolveInfo $info, FieldContext $field) { $branches = $this->branches; while ([$condition, $resolver] = array_pad(array_shift($branches), 2, NULL)) { while ($branch = array_shift($branches)) { [$condition, $resolver] = array_pad($branch, 2, NULL); if ($condition instanceof ResolverInterface) { if (($condition = $condition->resolve($value, $args, $context, $info, $field)) === NULL) { // Bail out early if a resolver returns NULL. Loading
tests/src/Kernel/ResolverBuilderTest.php +20 −0 Original line number Diff line number Diff line Loading @@ -231,6 +231,26 @@ GQL; $this->assertResults($query, [], ['tree' => ['context' => ['myContext' => 'my context value']]]); } /** * @covers ::cond */ public function testSingleCond(): void { $this->mockResolver('Query', 'me', $this->builder->cond([ [ $this->builder->fromValue(FALSE), $this->builder->fromValue('This should resolve into null.'), ], ])); $query = <<<GQL query { me } GQL; $this->assertResults($query, [], ['me' => NULL]); } /** * @covers ::cond */ Loading