@@ -33,11 +33,6 @@ class FieldsBuilder implements ConfigBuilderInterface
3333 protected ResolveInstructionBuilder $ resolveInstructionBuilder ;
3434 protected ValidationRulesBuilder $ validationRulesBuilder ;
3535
36- /**
37- * TODO: use single source for all usages (create a provider).
38- */
39- protected string $ gqlServices = '$ ' . TypeGenerator::GRAPHQL_SERVICES ;
40-
4136 public function __construct (
4237 ExpressionConverter $ expressionConverter ,
4338 ResolveInstructionBuilder $ resolveInstructionBuilder ,
@@ -241,11 +236,13 @@ protected function buildComplexity($complexity): GeneratorInterface
241236 $ expression = $ this ->expressionConverter ->convert ($ complexity );
242237
243238 if (EL ::expressionContainsVar ('args ' , $ complexity )) {
239+ $ gqlServices = TypeGenerator::GRAPHQL_SERVICES_EXPR ;
240+
244241 return Closure::new ()
245242 ->addArgument ('childrenComplexity ' )
246243 ->addArgument ('arguments ' , '' , [])
247244 ->bindVar (TypeGenerator::GRAPHQL_SERVICES )
248- ->append ('$args = ' , "$ this -> gqlServices ->get('argumentFactory')->create( \$arguments) " )
245+ ->append ('$args = ' , "{ $ gqlServices} ->get('argumentFactory')->create( \$arguments) " )
249246 ->append ('return ' , $ expression );
250247 }
251248
@@ -351,7 +348,8 @@ protected function wrapTypeRecursive($typeNode, bool &$isReference, PhpFile $php
351348 $ phpFile ->addUse (Type::class);
352349 } else {
353350 $ name = $ typeNode ->name ->value ;
354- $ type = "$ this ->gqlServices ->getType(' $ name') " ;
351+ $ gqlServices = TypeGenerator::GRAPHQL_SERVICES_EXPR ;
352+ $ type = "{$ gqlServices }->getType(' $ name') " ;
355353 $ isReference = true ;
356354 }
357355 break ;
0 commit comments