-
Notifications
You must be signed in to change notification settings - Fork 106
Expand file tree
/
Copy pathResolveInfoParameterHandler.php
More file actions
28 lines (22 loc) · 1.04 KB
/
ResolveInfoParameterHandler.php
File metadata and controls
28 lines (22 loc) · 1.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
<?php
declare(strict_types=1);
namespace TheCodingMachine\GraphQLite\Mappers\Parameters;
use GraphQL\Type\Definition\ResolveInfo;
use phpDocumentor\Reflection\DocBlock;
use phpDocumentor\Reflection\Type;
use ReflectionNamedType;
use ReflectionParameter;
use TheCodingMachine\GraphQLite\Annotations\ParameterAnnotations;
use TheCodingMachine\GraphQLite\Parameters\ParameterInterface;
use TheCodingMachine\GraphQLite\Parameters\ResolveInfoParameter;
class ResolveInfoParameterHandler implements ParameterMiddlewareInterface
{
public function mapParameter(ReflectionParameter $parameter, DocBlock $docBlock, Type|null $paramTagType, ParameterAnnotations $parameterAnnotations, ParameterHandlerInterface $parameterMapper): ParameterInterface
{
$type = $parameter->getType();
if ($type instanceof ReflectionNamedType && $type->getName() === ResolveInfo::class) {
return new ResolveInfoParameter();
}
return $parameterMapper->mapParameter($parameter, $docBlock, $paramTagType, $parameterAnnotations);
}
}