Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions src/Symfony/Bundle/DependencyInjection/ApiPlatformExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -583,13 +583,16 @@ private function registerGraphQlConfiguration(ContainerBuilder $container, array
$container->registerForAutoconfiguration(ErrorHandlerInterface::class)
->addTag('api_platform.graphql.error_handler');

if (!$container->getParameter('kernel.debug')) {
return;
}

/* TODO: remove these in 4.x only one resolver factory is used and we're using providers/processors */
if ($config['event_listeners_backward_compatibility_layer'] ?? true) {
// @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.');
// + deprecate every service from legacy/graphql.xml
$loader->load('legacy/graphql.xml');

if (!$container->getParameter('kernel.debug')) {
return;
}

$requestStack = new Reference('request_stack', ContainerInterface::NULL_ON_INVALID_REFERENCE);
$collectionDataCollectorResolverFactory = (new Definition(DataCollectorResolverFactory::class))
->setDecoratedService('api_platform.graphql.resolver.factory.collection')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1274,4 +1274,15 @@ public function testLegacyGraphQlConfigurationWithoutJsonFormat(): void
(new ApiPlatformExtension())->load($config, $this->container);
$this->assertArrayHasKey('json', $this->container->getParameter('api_platform.formats'));
}

/**
* @see https://github.com/api-platform/core/issues/5919
*/
public function testGraphQlLegacyConfigurationInDebugMode(): void
{
$config = self::DEFAULT_CONFIG;

(new ApiPlatformExtension())->load($config, $this->container);
$this->assertTrue($this->container->hasDefinition('api_platform.graphql.resolver.factory.item'));
}
}