Skip to content

Commit

Permalink
Add Lazy behavior when using resolver as a service
Browse files Browse the repository at this point in the history
  • Loading branch information
mcg-web committed Dec 29, 2021
1 parent f9f7552 commit ea86f8d
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/Generator/TypeBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -886,9 +886,14 @@ private function buildCallback(Callback $callback, array $argNames, ?callable $e
return $expressionBuilder($callback->expression);
}
} elseif (null !== $callback->id) {
$fn = "$this->gqlServices->get('$callback->id')";
$fnExpression = "$this->gqlServices->get('$callback->id')";
if (null !== $callback->method) {
$fnExpression = "[$fnExpression, '$callback->method']";
}

return Collection::numeric([$fn, $callback->method ?? '__invoke']);
return ArrowFunction::new()
->addArguments(...$argNames)
->setExpression(Literal::new("($fnExpression)(...\\func_get_args())"));
} else {
return Literal::new("'$callback->method'");
}
Expand Down

0 comments on commit ea86f8d

Please sign in to comment.