From 8a0c8b406232a06aeed08a67fbd71b97e2896e2d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9miah=20VALERIE?= Date: Mon, 13 Jun 2016 12:15:10 +0200 Subject: [PATCH] GraphiQL and React version can be manage using semantic config. (#52) --- Controller/GraphiQLController.php | 2 +- DependencyInjection/Configuration.php | 14 ++++++++++---- DependencyInjection/OverblogGraphQLExtension.php | 7 +++++++ Resources/config/services.yml | 2 -- composer.json | 2 +- 5 files changed, 19 insertions(+), 8 deletions(-) diff --git a/Controller/GraphiQLController.php b/Controller/GraphiQLController.php index 499f26a3e..d16c5fe1a 100644 --- a/Controller/GraphiQLController.php +++ b/Controller/GraphiQLController.php @@ -24,7 +24,7 @@ public function indexAction() 'versions' => [ 'graphiql' => $this->getParameter('overblog_graphql.versions.graphiql'), 'react' => $this->getParameter('overblog_graphql.versions.react'), - ] + ], ] ); } diff --git a/DependencyInjection/Configuration.php b/DependencyInjection/Configuration.php index 33ea86234..29cfe4b06 100644 --- a/DependencyInjection/Configuration.php +++ b/DependencyInjection/Configuration.php @@ -110,10 +110,16 @@ public function getConfigTreeBuilder() ->end() ->arrayNode('security') ->addDefaultsIfNotSet() - ->children() - ->append($this->addSecurityQuerySection('query_max_depth', QueryDepth::DISABLED)) - ->append($this->addSecurityQuerySection('query_max_complexity', QueryComplexity::DISABLED)) - ->end() + ->children() + ->append($this->addSecurityQuerySection('query_max_depth', QueryDepth::DISABLED)) + ->append($this->addSecurityQuerySection('query_max_complexity', QueryComplexity::DISABLED)) + ->end() + ->end() + ->arrayNode('versions') + ->addDefaultsIfNotSet() + ->children() + ->scalarNode('graphiql')->defaultValue('0.7.1')->end() + ->scalarNode('react')->defaultValue('15.0.2')->end() ->end() ->end() ->end(); diff --git a/DependencyInjection/OverblogGraphQLExtension.php b/DependencyInjection/OverblogGraphQLExtension.php index 30803f98f..e624f8b98 100644 --- a/DependencyInjection/OverblogGraphQLExtension.php +++ b/DependencyInjection/OverblogGraphQLExtension.php @@ -36,6 +36,7 @@ public function load(array $configs, ContainerBuilder $container) $this->setGraphiQLTemplate($config, $container); $this->setSecurity($config, $container); $this->setConfigBuilders($config); + $this->setVersions($config, $container); $container->setParameter($this->getAlias().'.resources_dir', realpath(__DIR__.'/../Resources')); } @@ -51,6 +52,12 @@ public function prepend(ContainerBuilder $container) $typesExtension->containerPrependExtensionConfig($config, $container); } + private function setVersions(array $config, ContainerBuilder $container) + { + $container->setParameter($this->getAlias().'.versions.graphiql', $config['versions']['graphiql']); + $container->setParameter($this->getAlias().'.versions.react', $config['versions']['react']); + } + private function setConfigBuilders(array $config) { foreach (['args', 'field'] as $category) { diff --git a/Resources/config/services.yml b/Resources/config/services.yml index ca2129656..d723c3453 100644 --- a/Resources/config/services.yml +++ b/Resources/config/services.yml @@ -1,8 +1,6 @@ parameters: overblog_graphql.default_resolver: [Overblog\GraphQLBundle\Resolver\Resolver, defaultResolveFn] overblog_graphql.type_class_namespace: "Overblog\\GraphQLBundle\\__DEFINITIONS__" - overblog_graphql.versions.graphiql: "0.7.1" - overblog_graphql.versions.react: "15.0.2" services: overblog_graphql.error_handler: diff --git a/composer.json b/composer.json index bcf693406..486ec8c33 100644 --- a/composer.json +++ b/composer.json @@ -29,7 +29,7 @@ "symfony/framework-bundle": "^2.7|^3.0", "symfony/options-resolver": "^2.7|^3.0", "symfony/property-access": "^2.7|^3.0", - "webonyx/graphql-php": "0.6.2" + "webonyx/graphql-php": "0.6.4" }, "suggest": { "twig/twig": "If you want to use graphiQL."