|
8 | 8 | use GraphQL\Type\Definition\ObjectType; |
9 | 9 | use phpDocumentor\Reflection\Fqsen; |
10 | 10 | use phpDocumentor\Reflection\Types\Object_; |
| 11 | +use Psr\Container\ContainerInterface; |
11 | 12 | use ReflectionClass; |
12 | 13 | use ReflectionMethod; |
13 | 14 | use ReflectionType; |
@@ -48,20 +49,26 @@ public function __construct(InputTypeUtils $inputTypeUtils, |
48 | 49 | } |
49 | 50 |
|
50 | 51 | /** |
51 | | - * @param object $factory |
| 52 | + * @param string $factory |
52 | 53 | * @param string $methodName |
53 | 54 | * @param RecursiveTypeMapperInterface $recursiveTypeMapper |
54 | 55 | * @return InputObjectType |
55 | 56 | */ |
56 | | - public function mapFactoryMethod($factory, string $methodName, RecursiveTypeMapperInterface $recursiveTypeMapper): InputObjectType |
| 57 | + public function mapFactoryMethod(string $factory, string $methodName, RecursiveTypeMapperInterface $recursiveTypeMapper, ContainerInterface $container): InputObjectType |
57 | 58 | { |
58 | 59 | $method = new ReflectionMethod($factory, $methodName); |
59 | 60 |
|
| 61 | + if ($method->isStatic()) { |
| 62 | + $object = $factory; |
| 63 | + } else { |
| 64 | + $object = $container->get($factory); |
| 65 | + } |
| 66 | + |
60 | 67 | [$inputName, $className] = $this->inputTypeUtils->getInputTypeNameAndClassName($method); |
61 | 68 |
|
62 | 69 | if (!isset($this->cache[$inputName])) { |
63 | 70 | // TODO: add comment argument. |
64 | | - $this->cache[$inputName] = new ResolvableInputObjectType($inputName, $this->fieldsBuilderFactory, $recursiveTypeMapper, $factory, $methodName, $this->hydrator, null); |
| 71 | + $this->cache[$inputName] = new ResolvableInputObjectType($inputName, $this->fieldsBuilderFactory, $recursiveTypeMapper, $object, $methodName, $this->hydrator, null); |
65 | 72 | } |
66 | 73 |
|
67 | 74 | return $this->cache[$inputName]; |
|
0 commit comments