Skip to content

Commit ea86f8d

Browse files
committed
Add Lazy behavior when using resolver as a service
1 parent f9f7552 commit ea86f8d

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

src/Generator/TypeBuilder.php

+7-2
Original file line numberDiff line numberDiff line change
@@ -886,9 +886,14 @@ private function buildCallback(Callback $callback, array $argNames, ?callable $e
886886
return $expressionBuilder($callback->expression);
887887
}
888888
} elseif (null !== $callback->id) {
889-
$fn = "$this->gqlServices->get('$callback->id')";
889+
$fnExpression = "$this->gqlServices->get('$callback->id')";
890+
if (null !== $callback->method) {
891+
$fnExpression = "[$fnExpression, '$callback->method']";
892+
}
890893

891-
return Collection::numeric([$fn, $callback->method ?? '__invoke']);
894+
return ArrowFunction::new()
895+
->addArguments(...$argNames)
896+
->setExpression(Literal::new("($fnExpression)(...\\func_get_args())"));
892897
} else {
893898
return Literal::new("'$callback->method'");
894899
}

0 commit comments

Comments
 (0)