Skip to content

Commit

Permalink
GraphiQL and React version can be manage using semantic config. (#52)
Browse files Browse the repository at this point in the history
  • Loading branch information
mcg-web authored Jun 13, 2016
1 parent da3366d commit 8a0c8b4
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 8 deletions.
2 changes: 1 addition & 1 deletion Controller/GraphiQLController.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public function indexAction()
'versions' => [
'graphiql' => $this->getParameter('overblog_graphql.versions.graphiql'),
'react' => $this->getParameter('overblog_graphql.versions.react'),
]
],
]
);
}
Expand Down
14 changes: 10 additions & 4 deletions DependencyInjection/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
7 changes: 7 additions & 0 deletions DependencyInjection/OverblogGraphQLExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'));
}
Expand All @@ -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) {
Expand Down
2 changes: 0 additions & 2 deletions Resources/config/services.yml
Original file line number Diff line number Diff line change
@@ -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:
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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."
Expand Down

0 comments on commit 8a0c8b4

Please sign in to comment.