Skip to content

Commit

Permalink
fix bundle configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
bpteam committed Mar 27, 2022
1 parent 606e63c commit e8df6fd
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 14 deletions.
17 changes: 9 additions & 8 deletions src/DependencyInjection/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,16 +28,21 @@ public function getConfigTreeBuilder(): TreeBuilder
->append($this->schemaFile())
->append($this->enablePreload())
->append($this->defaultResolver())
->append($this->addRequiredScalar(
->append($this->addScalar(
'namespace',
'App\GraphQL',
'Root namespace for generated code'
)->isRequired())
->append($this->addScalar(
'template_language_version',
'7.4',
'PHP version of templates for php code'
))
->append($this->addRequiredScalar(
->append($this->addScalar(
'dir',
'%kernel.project_dir%/src/GraphQL/',
'Root dir for generated code'
))
)->isRequired())
->end();

return $treeBuilder;
Expand Down Expand Up @@ -104,7 +109,7 @@ private function defaultResolver(): ScalarNodeDefinition
return $node;
}

private function addRequiredScalar(string $name, $default = null, string $info = null): ScalarNodeDefinition
private function addScalar(string $name, $default = null, string $info = null): ScalarNodeDefinition
{
$builder = new TreeBuilder($name, 'scalar');

Expand All @@ -119,10 +124,6 @@ private function addRequiredScalar(string $name, $default = null, string $info =
$node->defaultValue($default);
}

$node
->isRequired()
->end();

return $node;
}
}
11 changes: 5 additions & 6 deletions src/DependencyInjection/FlexibleGraphqlExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -156,16 +156,16 @@ private function registerConfigGenerator(array $config, ContainerBuilder $contai
{
$container->register(CodeGeneratorConfigInterface::class)
->setClass(CodeGeneratorConfig::class)
->setArgument('$namespace', $config['namespace'])
->setArgument('$dir', $config['dir']);
->setArgument('$dir', $config['dir'])
->setArgument('$phpVersion', $config['template_language_version'])
->setArgument('$namespace', $config['namespace']);
}

private function registerTypeRegistryGenerator(array $config, ContainerBuilder $container): void
{
$container->register(TypeRegistryGeneratorBuilderInterface::class)
->setClass(TypeRegistryGeneratorBuilder::class)
->setArgument('$namespace', $config['namespace'])
->setArgument('$dir', $config['dir']);
->setArgument('$config', new Reference(CodeGeneratorConfigInterface::class));
$container->setAlias(
'flexible_graphql.type_registry_generator.builder',
TypeRegistryGeneratorBuilderInterface::class
Expand All @@ -176,8 +176,7 @@ private function registerCodeGenerator(array $config, ContainerBuilder $containe
{
$codeGenerator = $container->register(CodeGeneratorBuilderInterface::class)
->setClass(CodeGeneratorBuilder::class)
->setArgument('$namespace', $config['namespace'])
->setArgument('$dir', $config['dir']);
->setArgument('$config', new Reference(CodeGeneratorConfigInterface::class));

if ($config['schema_type'] === Configuration::SCHEMA_TYPE_FEDERATION) {
$container->register(FieldResolverGeneratorConfigInterface::class)
Expand Down
1 change: 1 addition & 0 deletions src/Resources/config/flexible_graphql.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ flexible_graphql:
schema_files: '%kernel.project_dir%/config/graphql/*.graphql'
enable_preload: false
default_resolver: flexible_graphql.default_resolver
template_language_version: '7.4'

0 comments on commit e8df6fd

Please sign in to comment.