Skip to content

Commit 8a5ad8d

Browse files
committed
chore(symfony): missing negotiation dependency + throw when graphql enabled but not installed
1 parent 03d62b7 commit 8a5ad8d

File tree

3 files changed

+10
-5
lines changed

3 files changed

+10
-5
lines changed

docs/composer.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@
1515
}
1616
],
1717
"require": {
18-
"api-platform/core": "dev-main",
18+
"api-platform/symfony": "^3.4 || ^4.0",
19+
"api-platform/doctrine-orm": "^3.4 || ^4.0",
1920
"symfony/expression-language": "^7.0",
2021
"nelmio/cors-bundle": "^2.2",
2122
"phpstan/phpdoc-parser": "^1.15",
@@ -34,8 +35,7 @@
3435
"zenstruck/foundry": "^1.31",
3536
"symfony/http-client": "^7.0",
3637
"symfony/browser-kit": "^7.0",
37-
"justinrainbow/json-schema": "^5.2",
38-
"webonyx/graphql-php": "^15.11"
38+
"justinrainbow/json-schema": "^5.2"
3939
},
4040
"config": {
4141
"allow-plugins": {

src/Symfony/Bundle/DependencyInjection/ApiPlatformExtension.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
use ApiPlatform\Doctrine\Orm\State\LinksHandlerInterface as OrmLinksHandlerInterface;
2828
use ApiPlatform\Elasticsearch\Extension\RequestBodySearchCollectionExtensionInterface;
2929
use ApiPlatform\GraphQl\Error\ErrorHandlerInterface;
30+
use ApiPlatform\GraphQl\Executor;
3031
use ApiPlatform\GraphQl\Resolver\MutationResolverInterface;
3132
use ApiPlatform\GraphQl\Resolver\QueryCollectionResolverInterface;
3233
use ApiPlatform\GraphQl\Resolver\QueryItemResolverInterface;
@@ -648,7 +649,6 @@ private function registerJsonProblemConfiguration(array $errorFormats, XmlFileLo
648649
private function registerGraphQlConfiguration(ContainerBuilder $container, array $config, XmlFileLoader $loader): void
649650
{
650651
$enabled = $this->isConfigEnabled($container, $config['graphql']);
651-
652652
$graphqlIntrospectionEnabled = $enabled && $this->isConfigEnabled($container, $config['graphql']['introspection']);
653653

654654
$graphiqlEnabled = $enabled && $this->isConfigEnabled($container, $config['graphql']['graphiql']);
@@ -667,6 +667,10 @@ private function registerGraphQlConfiguration(ContainerBuilder $container, array
667667
return;
668668
}
669669

670+
if (!class_exists(Executor::class)) {
671+
throw new \RuntimeException('Graphql is enabled but not installed, run: composer require "api-platform/graphql".');
672+
}
673+
670674
$container->setParameter('api_platform.graphql.default_ide', $config['graphql']['default_ide']);
671675
$container->setParameter('api_platform.graphql.nesting_separator', $config['graphql']['nesting_separator']);
672676

src/Symfony/composer.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@
3333
"symfony/property-info": "^6.4 || ^7.1",
3434
"symfony/property-access": "^6.4 || ^7.1",
3535
"symfony/serializer": "^6.4 || ^7.1",
36-
"symfony/security-core": "^6.4 || ^7.0"
36+
"symfony/security-core": "^6.4 || ^7.0",
37+
"willdurand/negotiation": "^3.0"
3738
},
3839
"require-dev": {
3940
"phpspec/prophecy-phpunit": "^2.0",

0 commit comments

Comments
 (0)