Skip to content

Commit e80b6e2

Browse files
authored
Merge 264d1e5 into 3ce5878
2 parents 3ce5878 + 264d1e5 commit e80b6e2

File tree

15 files changed

+302
-311
lines changed

15 files changed

+302
-311
lines changed

DependencyInjection/Compiler/AliasedPass.php

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,22 @@
22

33
namespace Overblog\GraphQLBundle\DependencyInjection\Compiler;
44

5+
use GraphQL\Type\Definition\Type;
56
use Overblog\GraphQLBundle\Definition\Resolver\AliasedInterface;
7+
use Overblog\GraphQLBundle\Definition\Resolver\MutationInterface;
8+
use Overblog\GraphQLBundle\Definition\Resolver\ResolverInterface;
69
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
710
use Symfony\Component\DependencyInjection\ContainerBuilder;
811
use Symfony\Component\DependencyInjection\Definition;
912

1013
final class AliasedPass implements CompilerPassInterface
1114
{
15+
private const SERVICE_SUBCLASS_TAG_MAPPING = [
16+
MutationInterface::class => 'overblog_graphql.mutation',
17+
ResolverInterface::class => 'overblog_graphql.resolver',
18+
Type::class => TypeTaggedServiceMappingPass::TAG_NAME,
19+
];
20+
1221
/**
1322
* {@inheritdoc}
1423
*/
@@ -28,7 +37,7 @@ public function process(ContainerBuilder $container)
2837
private function filterDefinitions($definitions)
2938
{
3039
return array_filter($definitions, function (Definition $definition) {
31-
foreach (AutoMappingPass::SERVICE_SUBCLASS_TAG_MAPPING as $tagName) {
40+
foreach (self::SERVICE_SUBCLASS_TAG_MAPPING as $tagName) {
3241
if ($definition->hasTag($tagName)) {
3342
return is_subclass_of($definition->getClass(), AliasedInterface::class);
3443
}
@@ -55,7 +64,7 @@ private function addDefinitionTagsFromAliases(Definition $definition)
5564
private function guessTagName(Definition $definition)
5665
{
5766
$tagName = null;
58-
foreach (AutoMappingPass::SERVICE_SUBCLASS_TAG_MAPPING as $refClassName => $tag) {
67+
foreach (self::SERVICE_SUBCLASS_TAG_MAPPING as $refClassName => $tag) {
5968
if (is_subclass_of($definition->getClass(), $refClassName)) {
6069
$tagName = $tag;
6170
break;

DependencyInjection/Compiler/AutoMappingPass.php

Lines changed: 0 additions & 185 deletions
This file was deleted.

DependencyInjection/Configuration.php

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,6 @@ private function definitionsSection()
117117
->booleanNode('show_debug_info')->info('Show some performance stats in extensions')->defaultFalse()->end()
118118
->booleanNode('config_validation')->defaultValue($this->debug)->end()
119119
->append($this->definitionsSchemaSection())
120-
->append($this->definitionsAutoMappingSection())
121120
->append($this->definitionsMappingsSection())
122121
->arrayNode('builders')
123122
->children()
@@ -211,28 +210,6 @@ private function definitionsSchemaSection()
211210
return $node;
212211
}
213212

214-
private function definitionsAutoMappingSection()
215-
{
216-
$builder = new TreeBuilder();
217-
/** @var ArrayNodeDefinition $node */
218-
$node = $builder->root('auto_mapping');
219-
$node
220-
->treatFalseLike(['enabled' => false])
221-
->treatTrueLike(['enabled' => true])
222-
->treatNullLike(['enabled' => true])
223-
->addDefaultsIfNotSet()
224-
->children()
225-
->booleanNode('enabled')->defaultTrue()->end()
226-
->arrayNode('directories')
227-
->info('List of directories containing GraphQL classes.')
228-
->prototype('scalar')->end()
229-
->end()
230-
->end()
231-
->end();
232-
233-
return $node;
234-
}
235-
236213
private function definitionsMappingsSection()
237214
{
238215
$builder = new TreeBuilder();

DependencyInjection/OverblogGraphQLExtension.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ private function loadConfigFiles(ContainerBuilder $container)
7777
$loader = new YamlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
7878
$loader->load('services.yml');
7979
$loader->load('graphql_types.yml');
80+
$loader->load('graphql_resolvers.yml');
8081
$loader->load('expression_language_functions.yml');
8182
$loader->load('definition_config_processors.yml');
8283
}
@@ -110,9 +111,6 @@ private function setClassLoaderListener(array $config, ContainerBuilder $contain
110111

111112
private function setDefinitionParameters(array $config, ContainerBuilder $container)
112113
{
113-
// auto mapping
114-
$container->setParameter($this->getAlias().'.auto_mapping.enabled', $config['definitions']['auto_mapping']['enabled']);
115-
$container->setParameter($this->getAlias().'.auto_mapping.directories', $config['definitions']['auto_mapping']['directories']);
116114
// generator and config
117115
$container->setParameter($this->getAlias().'.default_resolver', $config['definitions']['default_resolver']);
118116
$container->setParameter($this->getAlias().'.class_namespace', $config['definitions']['class_namespace']);

DependencyInjection/OverblogGraphQLTypesExtension.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@ class OverblogGraphQLTypesExtension extends Extension
4242
public function load(array $configs, ContainerBuilder $container)
4343
{
4444
$configs = array_filter($configs);
45-
//$configs = array_filter($configs);
4645
if (count($configs) > 1) {
4746
throw new \InvalidArgumentException('Configs type should never contain more than one config to deal with inheritance.');
4847
}

OverblogGraphQLBundle.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
namespace Overblog\GraphQLBundle;
44

55
use Overblog\GraphQLBundle\DependencyInjection\Compiler\AliasedPass;
6-
use Overblog\GraphQLBundle\DependencyInjection\Compiler\AutoMappingPass;
76
use Overblog\GraphQLBundle\DependencyInjection\Compiler\AutowiringTypesPass;
87
use Overblog\GraphQLBundle\DependencyInjection\Compiler\ConfigTypesPass;
98
use Overblog\GraphQLBundle\DependencyInjection\Compiler\DefinitionConfigProcessorPass;
@@ -28,11 +27,10 @@ public function build(ContainerBuilder $container)
2827
{
2928
parent::build($container);
3029

31-
//ConfigTypesPass and AutoMappingPass must be before TypeTaggedServiceMappingPass
30+
//ConfigTypesPass must be before TypeTaggedServiceMappingPass
3231
$container->addCompilerPass(new GlobalVariablesPass());
3332
$container->addCompilerPass(new ExpressionFunctionPass());
3433
$container->addCompilerPass(new DefinitionConfigProcessorPass());
35-
$container->addCompilerPass(new AutoMappingPass());
3634
$container->addCompilerPass(new AliasedPass());
3735
$container->addCompilerPass(new AutowiringTypesPass());
3836

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
services:
2+
_defaults:
3+
autowire: true
4+
public: true
5+
6+
_instanceof:
7+
Overblog\GraphQLBundle\Definition\Resolver\ResolverInterface:
8+
tags: ['overblog_graphql.resolver']
9+
Overblog\GraphQLBundle\Definition\Resolver\MutationInterface:
10+
tags: ['overblog_graphql.mutation']
11+
12+
Overblog\GraphQLBundle\GraphQL\Relay\:
13+
resource: ../../GraphQL/Relay/{Mutation,Node}

Resources/doc/definitions/resolver.md

Lines changed: 8 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -132,36 +132,18 @@ class CalcMutation implements MutationInterface, AliasedInterface
132132
`addition` mutation can be access by using `App\GraphQL\Mutation\CalcMutation::addition` or
133133
`add` alias.
134134

135-
You can also define custom dirs using the config (Symfony <3.3):
136-
```yaml
137-
overblog_graphql:
138-
definitions:
139-
auto_mapping:
140-
directories:
141-
- "%kernel.root_dir%/src/*Bundle/CustomDir"
142-
- "%kernel.root_dir%/src/AppBundle/{foo,bar}"
143-
```
144-
145-
If using Symfony 3.3+ disabling auto mapping can be a solution to leave place to native
146-
DI `autoconfigure`:
147-
148-
```yaml
149-
overblog_graphql:
150-
definitions:
151-
auto_mapping: false
152-
```
153-
154135
Here an example of how this can be done with DI `autoconfigure`:
155136

156137
```yaml
157138
services:
158-
App\Mutation\:
159-
resource: '../src/Mutation'
160-
tags: ['overblog_graphql.mutation']
161-
162-
App\Resolver\:
163-
resource: '../src/Resolver'
164-
tags: ['overblog_graphql.resolver']
139+
_instanceof:
140+
Overblog\GraphQLBundle\Definition\Resolver\ResolverInterface:
141+
tags: ['overblog_graphql.resolver']
142+
Overblog\GraphQLBundle\Definition\Resolver\MutationInterface:
143+
tags: ['overblog_graphql.mutation']
144+
145+
Overblog\GraphQLBundle\GraphQL\Relay\:
146+
resource: ../../GraphQL/Relay/{Mutation,Node}
165147
```
166148

167149
## The service way

Resources/doc/definitions/type-system/index.md

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -68,25 +68,6 @@ Types can be define 3 different ways:
6868
}
6969
```
7070

71-
You can also define custom dirs using config:
72-
```yaml
73-
overblog_graphql:
74-
definitions:
75-
auto_mapping:
76-
directories:
77-
- "%kernel.root_dir%/src/*Bundle/CustomDir"
78-
- "%kernel.root_dir%/src/AppBundle/{foo,bar}"
79-
```
80-
81-
If using Symfony 3.3+ disabling auto mapping can be a solution to leave place to native
82-
DI `autoconfigure`:
83-
84-
```yaml
85-
overblog_graphql:
86-
definitions:
87-
auto_mapping: false
88-
```
89-
9071
Here an example of how this can be done with DI `autoconfigure`:
9172

9273
```yaml

0 commit comments

Comments
 (0)