diff --git a/DependencyInjection/Compiler/AutowiringTypesPass.php b/DependencyInjection/Compiler/AutowiringTypesPass.php new file mode 100644 index 000000000..0a2f5b989 --- /dev/null +++ b/DependencyInjection/Compiler/AutowiringTypesPass.php @@ -0,0 +1,29 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Overblog\GraphQLBundle\DependencyInjection\Compiler; + +use GraphQL\Executor\Promise\PromiseAdapter; +use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface; +use Symfony\Component\DependencyInjection\ContainerBuilder; + +class AutowiringTypesPass implements CompilerPassInterface +{ + /** + * You can modify the container here before it is dumped to PHP code. + * + * @param ContainerBuilder $container + */ + public function process(ContainerBuilder $container) + { + $container->findDefinition('overblog_graphql.promise_adapter')->setAutowiringTypes([PromiseAdapter::class]); + } +} diff --git a/DependencyInjection/OverblogGraphQLExtension.php b/DependencyInjection/OverblogGraphQLExtension.php index 9a01281ea..33812dcce 100644 --- a/DependencyInjection/OverblogGraphQLExtension.php +++ b/DependencyInjection/OverblogGraphQLExtension.php @@ -11,7 +11,6 @@ namespace Overblog\GraphQLBundle\DependencyInjection; -use GraphQL\Executor\Promise\PromiseAdapter; use GraphQL\Schema; use Overblog\GraphQLBundle\Config\TypeWithOutputFieldsDefinition; use Symfony\Component\Config\FileLocator; @@ -173,7 +172,6 @@ private function setServicesAliases(array $config, ContainerBuilder $container) $container->setAlias($alias, $id); // set autowiring types for promise adapter service if ($this->getAlias().'.promise_adapter' === $alias) { - $container->findDefinition($id)->setAutowiringTypes([PromiseAdapter::class]); } } } diff --git a/OverblogGraphQLBundle.php b/OverblogGraphQLBundle.php index 5bacd8124..a1d96d3b4 100644 --- a/OverblogGraphQLBundle.php +++ b/OverblogGraphQLBundle.php @@ -12,6 +12,7 @@ namespace Overblog\GraphQLBundle; use Overblog\GraphQLBundle\DependencyInjection\Compiler\AutoMappingPass; +use Overblog\GraphQLBundle\DependencyInjection\Compiler\AutowiringTypesPass; use Overblog\GraphQLBundle\DependencyInjection\Compiler\ConfigTypesPass; use Overblog\GraphQLBundle\DependencyInjection\Compiler\MutationTaggedServiceMappingTaggedPass; use Overblog\GraphQLBundle\DependencyInjection\Compiler\ResolverTaggedServiceMappingPass; @@ -35,10 +36,11 @@ public function build(ContainerBuilder $container) //ConfigTypesPass and AutoMappingPass must be before TypeTaggedServiceMappingPass $container->addCompilerPass(new AutoMappingPass()); $container->addCompilerPass(new ConfigTypesPass()); + $container->addCompilerPass(new AutowiringTypesPass()); - $container->addCompilerPass(new TypeTaggedServiceMappingPass(), PassConfig::TYPE_OPTIMIZE); - $container->addCompilerPass(new ResolverTaggedServiceMappingPass(), PassConfig::TYPE_OPTIMIZE); - $container->addCompilerPass(new MutationTaggedServiceMappingTaggedPass(), PassConfig::TYPE_OPTIMIZE); + $container->addCompilerPass(new TypeTaggedServiceMappingPass(), PassConfig::TYPE_BEFORE_REMOVING); + $container->addCompilerPass(new ResolverTaggedServiceMappingPass(), PassConfig::TYPE_BEFORE_REMOVING); + $container->addCompilerPass(new MutationTaggedServiceMappingTaggedPass(), PassConfig::TYPE_BEFORE_REMOVING); $container->registerExtension(new OverblogGraphQLTypesExtension()); }