Skip to content

Commit

Permalink
Merge pull request #35 from moufmouf/parameter_middleware
Browse files Browse the repository at this point in the history
Adapting code to new parameter middleware
  • Loading branch information
moufmouf committed Oct 4, 2019
2 parents 3ff6bdb + 4feb437 commit 7b836f9
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 12 deletions.
2 changes: 1 addition & 1 deletion DependencyInjection/GraphqliteCompilerPass.php
Expand Up @@ -243,7 +243,7 @@ public function process(ContainerBuilder $container)
$this->mapAdderToTag('graphql.queryprovider', 'addQueryProvider', $container, $schemaFactory);
$this->mapAdderToTag('graphql.queryprovider_factory', 'addQueryProviderFactory', $container, $schemaFactory);
$this->mapAdderToTag('graphql.root_type_mapper', 'addRootTypeMapper', $container, $schemaFactory);
$this->mapAdderToTag('graphql.parameter_mapper', 'addParameterMapper', $container, $schemaFactory);
$this->mapAdderToTag('graphql.parameter_middleware', 'addParameterMiddleware', $container, $schemaFactory);
$this->mapAdderToTag('graphql.field_middleware', 'addFieldMiddleware', $container, $schemaFactory);
$this->mapAdderToTag('graphql.type_mapper', 'addTypeMapper', $container, $schemaFactory);
$this->mapAdderToTag('graphql.type_mapper_factory', 'addTypeMapperFactory', $container, $schemaFactory);
Expand Down
Expand Up @@ -9,17 +9,18 @@
use ReflectionParameter;
use Symfony\Component\HttpFoundation\Request;
use TheCodingMachine\GraphQLite\Annotations\ParameterAnnotations;
use TheCodingMachine\GraphQLite\Mappers\Parameters\ParameterMapperInterface;
use TheCodingMachine\GraphQLite\Mappers\Parameters\ParameterHandlerInterface;
use TheCodingMachine\GraphQLite\Mappers\Parameters\ParameterMiddlewareInterface;
use TheCodingMachine\GraphQLite\Parameters\ParameterInterface;

class RequestParameterMapper implements ParameterMapperInterface
class RequestParameterMiddleware implements ParameterMiddlewareInterface
{

public function mapParameter(ReflectionParameter $parameter, DocBlock $docBlock, ?Type $paramTagType, ParameterAnnotations $parameterAnnotations): ?ParameterInterface
public function mapParameter(ReflectionParameter $parameter, DocBlock $docBlock, ?Type $paramTagType, ParameterAnnotations $parameterAnnotations, ParameterHandlerInterface $next): ParameterInterface
{
if ($parameter->getType()->getName() === Request::class) {
return new RequestParameter();
}
return null;
return $next->mapParameter($parameter, $docBlock, $paramTagType, $parameterAnnotations);
}
}
}
8 changes: 2 additions & 6 deletions Resources/config/container/graphqlite.xml
Expand Up @@ -65,12 +65,8 @@

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

<service id="TheCodingMachine\Graphqlite\Bundle\Mappers\RequestParameterMapper">
<tag name="graphql.parameter_mapper"/>
</service>

<service id="TheCodingMachine\Graphqlite\Bundle\Mappers\RequestParameterMapper">
<tag name="graphql.parameter_mapper"/>
<service id="TheCodingMachine\Graphqlite\Bundle\Mappers\RequestParameterMiddleware">
<tag name="graphql.parameter_middleware"/>
</service>

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

0 comments on commit 7b836f9

Please sign in to comment.