1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Digia\GraphQL\Schema\Resolver; |
4
|
|
|
|
5
|
|
|
use Digia\GraphQL\Execution\ResolveInfo; |
6
|
|
|
|
7
|
|
|
abstract class AbstractResolver implements ResolverInterface |
8
|
|
|
{ |
9
|
|
|
/** |
10
|
|
|
* @param mixed $rootValue |
11
|
|
|
* @param array $arguments |
12
|
|
|
* @param mixed $context |
13
|
|
|
* @param ResolveInfo|null $info |
14
|
|
|
* @return mixed |
15
|
|
|
*/ |
16
|
|
|
abstract public function resolve($rootValue, array $arguments, $context = null, ?ResolveInfo $info = null); |
17
|
|
|
|
18
|
|
|
/** |
19
|
|
|
* @return mixed |
20
|
|
|
*/ |
21
|
|
|
public function __invoke() |
22
|
|
|
{ |
23
|
|
|
return $this->resolve(...\func_get_args()); |
24
|
|
|
} |
25
|
|
|
|
26
|
|
|
/** |
27
|
|
|
* @inheritdoc |
28
|
|
|
*/ |
29
|
|
|
public function getResolveCallback(): ?callable |
30
|
|
|
{ |
31
|
|
|
return function ($rootValue, array $arguments, $context = null, ?ResolveInfo $info = null) { |
32
|
|
|
return $this->resolve($rootValue, $arguments, $context, $info); |
33
|
|
|
}; |
34
|
|
|
} |
35
|
|
|
|
36
|
|
|
/** |
37
|
|
|
* @inheritdoc |
38
|
|
|
*/ |
39
|
|
|
public function getTypeResolver(): ?callable |
40
|
|
|
{ |
41
|
|
|
return function ($rootValue, $context = null, ?ResolveInfo $info = null) { |
42
|
|
|
return $this->resolveType($rootValue, $context, $info); |
|
|
|
|
43
|
|
|
}; |
44
|
|
|
} |
45
|
|
|
|
46
|
|
|
/** |
47
|
|
|
* @param mixed $rootValue |
48
|
|
|
* @param mixed $context |
49
|
|
|
* @param ResolveInfo|null $info |
50
|
|
|
* @return callable|null |
51
|
|
|
*/ |
52
|
|
|
public function resolveType($rootValue, $context = null, ?ResolveInfo $info = null): ?callable |
|
|
|
|
53
|
|
|
{ |
54
|
|
|
// Override this method when your resolver returns an interface or an union type. |
55
|
|
|
return null; |
56
|
|
|
} |
57
|
|
|
|
58
|
|
|
/** |
59
|
|
|
* @inheritdoc |
60
|
|
|
*/ |
61
|
|
|
public function getMiddleware(): ?array |
62
|
|
|
{ |
63
|
|
|
return null; |
64
|
|
|
} |
65
|
|
|
} |
66
|
|
|
|
This check looks for function or method calls that always return null and whose return value is used.
The method
getObject()
can return nothing but null, so it makes no sense to use the return value.The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.