Skip to content

Commit e0bae07

Browse files
committed
Adding an interface for InputTypeParameter (in order to be able to create ParameterInterface that behaves like real input type (for Validators))
1 parent a20e8d8 commit e0bae07

File tree

3 files changed

+32
-4
lines changed

3 files changed

+32
-4
lines changed

src/InputTypeUtils.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
use ReflectionClass;
1414
use ReflectionMethod;
1515
use RuntimeException;
16-
use TheCodingMachine\GraphQLite\Parameters\InputTypeParameter;
16+
use TheCodingMachine\GraphQLite\Parameters\InputTypeParameterInterface;
1717
use TheCodingMachine\GraphQLite\Parameters\ParameterInterface;
1818
use Webmozart\Assert\Assert;
1919
use function array_filter;
@@ -101,10 +101,10 @@ private function resolveSelf(Type $type, ReflectionClass $reflectionClass): Type
101101
public static function getInputTypeArgs(array $args): array
102102
{
103103
$inputTypeArgs = array_filter($args, static function (ParameterInterface $parameter) {
104-
return $parameter instanceof InputTypeParameter;
104+
return $parameter instanceof InputTypeParameterInterface;
105105
});
106106

107-
return array_map(static function (InputTypeParameter $parameter) {
107+
return array_map(static function (InputTypeParameterInterface $parameter) {
108108
$desc = [
109109
'type' => $parameter->getType(),
110110
];

src/Parameters/InputTypeParameter.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
use TheCodingMachine\GraphQLite\Types\ArgumentResolver;
1111
use TheCodingMachine\GraphQLite\Types\ResolvableMutableInputObjectType;
1212

13-
class InputTypeParameter implements ParameterInterface
13+
class InputTypeParameter implements InputTypeParameterInterface
1414
{
1515
/** @var string */
1616
private $name;
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace TheCodingMachine\GraphQLite\Parameters;
6+
7+
use GraphQL\Type\Definition\InputType;
8+
use GraphQL\Type\Definition\ResolveInfo;
9+
10+
interface InputTypeParameterInterface extends ParameterInterface
11+
{
12+
/**
13+
* @param array<string, mixed> $args
14+
* @param mixed $context
15+
*
16+
* @return mixed
17+
*/
18+
public function resolve(?object $source, array $args, $context, ResolveInfo $info);
19+
20+
public function getType(): InputType;
21+
22+
public function hasDefaultValue(): bool;
23+
24+
/**
25+
* @return mixed
26+
*/
27+
public function getDefaultValue();
28+
}

0 commit comments

Comments
 (0)