Skip to content

Commit 5882990

Browse files
authored
Add GraphQL Playground and bump dependencies (#2961)
1 parent 6e47bba commit 5882990

30 files changed

+1124
-499
lines changed

src/Bridge/Symfony/Bundle/Action/SwaggerUiAction.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,9 @@ final class SwaggerUiAction
5555
private $reDocEnabled;
5656
private $graphqlEnabled;
5757
private $graphiQlEnabled;
58+
private $graphQlPlaygroundEnabled;
5859

59-
public function __construct(ResourceNameCollectionFactoryInterface $resourceNameCollectionFactory, ResourceMetadataFactoryInterface $resourceMetadataFactory, NormalizerInterface $normalizer, TwigEnvironment $twig, UrlGeneratorInterface $urlGenerator, string $title = '', string $description = '', string $version = '', $formats = [], $oauthEnabled = false, $oauthClientId = '', $oauthClientSecret = '', $oauthType = '', $oauthFlow = '', $oauthTokenUrl = '', $oauthAuthorizationUrl = '', $oauthScopes = [], bool $showWebby = true, bool $swaggerUiEnabled = false, bool $reDocEnabled = false, bool $graphqlEnabled = false, bool $graphiQlEnabled = false)
60+
public function __construct(ResourceNameCollectionFactoryInterface $resourceNameCollectionFactory, ResourceMetadataFactoryInterface $resourceMetadataFactory, NormalizerInterface $normalizer, TwigEnvironment $twig, UrlGeneratorInterface $urlGenerator, string $title = '', string $description = '', string $version = '', $formats = [], $oauthEnabled = false, $oauthClientId = '', $oauthClientSecret = '', $oauthType = '', $oauthFlow = '', $oauthTokenUrl = '', $oauthAuthorizationUrl = '', $oauthScopes = [], bool $showWebby = true, bool $swaggerUiEnabled = false, bool $reDocEnabled = false, bool $graphqlEnabled = false, bool $graphiQlEnabled = false, bool $graphQlPlaygroundEnabled = false)
6061
{
6162
$this->resourceNameCollectionFactory = $resourceNameCollectionFactory;
6263
$this->resourceMetadataFactory = $resourceMetadataFactory;
@@ -79,6 +80,7 @@ public function __construct(ResourceNameCollectionFactoryInterface $resourceName
7980
$this->reDocEnabled = $reDocEnabled;
8081
$this->graphqlEnabled = $graphqlEnabled;
8182
$this->graphiQlEnabled = $graphiQlEnabled;
83+
$this->graphQlPlaygroundEnabled = $graphQlPlaygroundEnabled;
8284

8385
if (\is_array($formats)) {
8486
$this->formats = $formats;
@@ -122,6 +124,7 @@ private function getContext(Request $request, Documentation $documentation): arr
122124
'reDocEnabled' => $this->reDocEnabled,
123125
'graphqlEnabled' => $this->graphqlEnabled,
124126
'graphiQlEnabled' => $this->graphiQlEnabled,
127+
'graphQlPlaygroundEnabled' => $this->graphQlPlaygroundEnabled,
125128
];
126129

127130
$swaggerContext = ['spec_version' => $request->query->getInt('spec_version', 2)];

src/Bridge/Symfony/Bundle/DependencyInjection/ApiPlatformExtension.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -370,6 +370,7 @@ private function registerGraphQlConfiguration(ContainerBuilder $container, array
370370

371371
$container->setParameter('api_platform.graphql.enabled', $enabled);
372372
$container->setParameter('api_platform.graphql.graphiql.enabled', $enabled && $this->isConfigEnabled($container, $config['graphql']['graphiql']));
373+
$container->setParameter('api_platform.graphql.graphql_playground.enabled', $enabled && $this->isConfigEnabled($container, $config['graphql']['graphql_playground']));
373374

374375
if (!$enabled) {
375376
return;

src/Bridge/Symfony/Bundle/DependencyInjection/Configuration.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,9 @@ private function addGraphQlSection(ArrayNodeDefinition $rootNode): void
226226
->arrayNode('graphiql')
227227
->{class_exists(GraphQL::class) && class_exists(TwigBundle::class) ? 'canBeDisabled' : 'canBeEnabled'}()
228228
->end()
229+
->arrayNode('graphql_playground')
230+
->{class_exists(GraphQL::class) && class_exists(TwigBundle::class) ? 'canBeDisabled' : 'canBeEnabled'}()
231+
->end()
229232
->end()
230233
->end()
231234
->end();

src/Bridge/Symfony/Bundle/Resources/config/api.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
<argument>%api_platform.enable_entrypoint%</argument>
4444
<argument>%api_platform.enable_docs%</argument>
4545
<argument>%api_platform.graphql.graphiql.enabled%</argument>
46+
<argument>%api_platform.graphql.graphql_playground.enabled%</argument>
4647

4748
<tag name="routing.loader" />
4849
</service>

src/Bridge/Symfony/Bundle/Resources/config/graphql.xml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,8 +113,10 @@
113113
<argument type="service" id="api_platform.graphql.schema_builder" />
114114
<argument type="service" id="api_platform.graphql.executor" />
115115
<argument type="service" id="api_platform.graphql.action.graphiql" />
116+
<argument type="service" id="api_platform.graphql.action.graphql_playground" />
116117
<argument>%kernel.debug%</argument>
117118
<argument>%api_platform.graphql.graphiql.enabled%</argument>
119+
<argument>%api_platform.graphql.graphql_playground.enabled%</argument>
118120
<argument>%api_platform.graphql.default_ide%</argument>
119121
</service>
120122

@@ -125,6 +127,13 @@
125127
<argument>%api_platform.title%</argument>
126128
</service>
127129

130+
<service id="api_platform.graphql.action.graphql_playground" class="ApiPlatform\Core\GraphQl\Action\GraphQlPlaygroundAction" public="true">
131+
<argument type="service" id="twig" />
132+
<argument type="service" id="api_platform.router" />
133+
<argument>%api_platform.graphql.graphql_playground.enabled%</argument>
134+
<argument>%api_platform.title%</argument>
135+
</service>
136+
128137
<!-- Serializer -->
129138

130139
<service id="api_platform.graphql.normalizer.item" class="ApiPlatform\Core\GraphQl\Serializer\ItemNormalizer" public="false">
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<?xml version="1.0" encoding="UTF-8" ?>
2+
3+
<routes xmlns="http://symfony.com/schema/routing"
4+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
5+
xsi:schemaLocation="http://symfony.com/schema/routing
6+
http://symfony.com/schema/routing/routing-1.0.xsd">
7+
8+
<route id="api_graphql_graphql_playground" path="/graphql/graphql_playground">
9+
<default key="_controller">api_platform.graphql.action.graphql_playground</default>
10+
</route>
11+
12+
</routes>

src/Bridge/Symfony/Bundle/Resources/config/swagger-ui.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
<argument>%api_platform.enable_re_doc%</argument>
3434
<argument>%api_platform.graphql.enabled%</argument>
3535
<argument>%api_platform.graphql.graphiql.enabled%</argument>
36+
<argument>%api_platform.graphql.graphql_playground.enabled%</argument>
3637
</service>
3738

3839
</services>

0 commit comments

Comments
 (0)