Skip to content

Commit d9f7740

Browse files
authored
fix(graphql): service missing in debug mode (#5930)
fixes #5919
1 parent c2824c1 commit d9f7740

File tree

2 files changed

+18
-4
lines changed

2 files changed

+18
-4
lines changed

src/Symfony/Bundle/DependencyInjection/ApiPlatformExtension.php

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -583,13 +583,16 @@ private function registerGraphQlConfiguration(ContainerBuilder $container, array
583583
$container->registerForAutoconfiguration(ErrorHandlerInterface::class)
584584
->addTag('api_platform.graphql.error_handler');
585585

586-
if (!$container->getParameter('kernel.debug')) {
587-
return;
588-
}
589-
590586
/* TODO: remove these in 4.x only one resolver factory is used and we're using providers/processors */
591587
if ($config['event_listeners_backward_compatibility_layer'] ?? true) {
588+
// @TODO: API Platform 3.3 trigger_deprecation('api-platform/core', '3.3', 'In API Platform 4 only one factory "api_platform.graphql.resolver.factory.item" will remain. Stages are deprecated in favor of using a provider/processor.');
589+
// + deprecate every service from legacy/graphql.xml
592590
$loader->load('legacy/graphql.xml');
591+
592+
if (!$container->getParameter('kernel.debug')) {
593+
return;
594+
}
595+
593596
$requestStack = new Reference('request_stack', ContainerInterface::NULL_ON_INVALID_REFERENCE);
594597
$collectionDataCollectorResolverFactory = (new Definition(DataCollectorResolverFactory::class))
595598
->setDecoratedService('api_platform.graphql.resolver.factory.collection')

tests/Symfony/Bundle/DependencyInjection/ApiPlatformExtensionTest.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1274,4 +1274,15 @@ public function testLegacyGraphQlConfigurationWithoutJsonFormat(): void
12741274
(new ApiPlatformExtension())->load($config, $this->container);
12751275
$this->assertArrayHasKey('json', $this->container->getParameter('api_platform.formats'));
12761276
}
1277+
1278+
/**
1279+
* @see https://github.com/api-platform/core/issues/5919
1280+
*/
1281+
public function testGraphQlLegacyConfigurationInDebugMode(): void
1282+
{
1283+
$config = self::DEFAULT_CONFIG;
1284+
1285+
(new ApiPlatformExtension())->load($config, $this->container);
1286+
$this->assertTrue($this->container->hasDefinition('api_platform.graphql.resolver.factory.item'));
1287+
}
12771288
}

0 commit comments

Comments
 (0)