Skip to content

Commit 7b836f9

Browse files
authored
Merge pull request #35 from moufmouf/parameter_middleware
Adapting code to new parameter middleware
2 parents 3ff6bdb + 4feb437 commit 7b836f9

File tree

3 files changed

+9
-12
lines changed

3 files changed

+9
-12
lines changed

DependencyInjection/GraphqliteCompilerPass.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@ public function process(ContainerBuilder $container)
243243
$this->mapAdderToTag('graphql.queryprovider', 'addQueryProvider', $container, $schemaFactory);
244244
$this->mapAdderToTag('graphql.queryprovider_factory', 'addQueryProviderFactory', $container, $schemaFactory);
245245
$this->mapAdderToTag('graphql.root_type_mapper', 'addRootTypeMapper', $container, $schemaFactory);
246-
$this->mapAdderToTag('graphql.parameter_mapper', 'addParameterMapper', $container, $schemaFactory);
246+
$this->mapAdderToTag('graphql.parameter_middleware', 'addParameterMiddleware', $container, $schemaFactory);
247247
$this->mapAdderToTag('graphql.field_middleware', 'addFieldMiddleware', $container, $schemaFactory);
248248
$this->mapAdderToTag('graphql.type_mapper', 'addTypeMapper', $container, $schemaFactory);
249249
$this->mapAdderToTag('graphql.type_mapper_factory', 'addTypeMapperFactory', $container, $schemaFactory);

Mappers/RequestParameterMapper.php renamed to Mappers/RequestParameterMiddleware.php

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,17 +9,18 @@
99
use ReflectionParameter;
1010
use Symfony\Component\HttpFoundation\Request;
1111
use TheCodingMachine\GraphQLite\Annotations\ParameterAnnotations;
12-
use TheCodingMachine\GraphQLite\Mappers\Parameters\ParameterMapperInterface;
12+
use TheCodingMachine\GraphQLite\Mappers\Parameters\ParameterHandlerInterface;
13+
use TheCodingMachine\GraphQLite\Mappers\Parameters\ParameterMiddlewareInterface;
1314
use TheCodingMachine\GraphQLite\Parameters\ParameterInterface;
1415

15-
class RequestParameterMapper implements ParameterMapperInterface
16+
class RequestParameterMiddleware implements ParameterMiddlewareInterface
1617
{
1718

18-
public function mapParameter(ReflectionParameter $parameter, DocBlock $docBlock, ?Type $paramTagType, ParameterAnnotations $parameterAnnotations): ?ParameterInterface
19+
public function mapParameter(ReflectionParameter $parameter, DocBlock $docBlock, ?Type $paramTagType, ParameterAnnotations $parameterAnnotations, ParameterHandlerInterface $next): ParameterInterface
1920
{
2021
if ($parameter->getType()->getName() === Request::class) {
2122
return new RequestParameter();
2223
}
23-
return null;
24+
return $next->mapParameter($parameter, $docBlock, $paramTagType, $parameterAnnotations);
2425
}
25-
}
26+
}

Resources/config/container/graphqlite.xml

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -65,12 +65,8 @@
6565

6666
<service id="TheCodingMachine\Graphqlite\Bundle\Controller\GraphqliteController" public="true" />
6767

68-
<service id="TheCodingMachine\Graphqlite\Bundle\Mappers\RequestParameterMapper">
69-
<tag name="graphql.parameter_mapper"/>
70-
</service>
71-
72-
<service id="TheCodingMachine\Graphqlite\Bundle\Mappers\RequestParameterMapper">
73-
<tag name="graphql.parameter_mapper"/>
68+
<service id="TheCodingMachine\Graphqlite\Bundle\Mappers\RequestParameterMiddleware">
69+
<tag name="graphql.parameter_middleware"/>
7470
</service>
7571

7672
<service id="TheCodingMachine\Graphqlite\Bundle\Controller\GraphQL\LoginController" public="true">

0 commit comments

Comments
 (0)