|
4 | 4 |
|
5 | 5 | use Psr\Log\LoggerInterface; |
6 | 6 | use Symfony\Component\DependencyInjection\ContainerAwareInterface; |
| 7 | +use Symfony\Component\HttpKernel\Kernel; |
7 | 8 | use Youshido\GraphQL\Execution\Context\ExecutionContextInterface; |
8 | 9 | use Youshido\GraphQL\Execution\Processor as BaseProcessor; |
9 | 10 | use Youshido\GraphQL\Execution\ResolveInfo; |
@@ -74,14 +75,25 @@ protected function resolveQuery(Query $query) |
74 | 75 | return parent::resolveQuery($query); |
75 | 76 | } |
76 | 77 |
|
| 78 | + private function dispatchResolveEvent(ResolveEvent $event, $name){ |
| 79 | + $major = Kernel::MAJOR_VERSION; |
| 80 | + $minor = Kernel::MINOR_VERSION; |
| 81 | + |
| 82 | + if($major > 4 || ($major === 4 && $minor >= 3)){ |
| 83 | + $this->eventDispatcher->dispatch($event, $name); |
| 84 | + }else{ |
| 85 | + $this->eventDispatcher->dispatch($name, $event); |
| 86 | + } |
| 87 | + } |
| 88 | + |
77 | 89 | protected function doResolve(FieldInterface $field, AstFieldInterface $ast, $parentValue = null) |
78 | 90 | { |
79 | 91 | /** @var AstQuery|AstField $ast */ |
80 | 92 | $arguments = $this->parseArgumentsValues($field, $ast); |
81 | 93 | $astFields = $ast instanceof AstQuery ? $ast->getFields() : []; |
82 | 94 |
|
83 | 95 | $event = new ResolveEvent($field, $astFields); |
84 | | - $this->eventDispatcher->dispatch('graphql.pre_resolve', $event); |
| 96 | + $this->dispatchResolveEvent($event, 'graphql.pre_resolve'); |
85 | 97 |
|
86 | 98 | $resolveInfo = $this->createResolveInfo($field, $astFields); |
87 | 99 | $this->assertClientHasFieldAccess($resolveInfo); |
@@ -116,7 +128,7 @@ protected function doResolve(FieldInterface $field, AstFieldInterface $ast, $par |
116 | 128 | } |
117 | 129 |
|
118 | 130 | $event = new ResolveEvent($field, $astFields, $result); |
119 | | - $this->eventDispatcher->dispatch('graphql.post_resolve', $event); |
| 131 | + $this->dispatchResolveEvent($event, 'graphql.post_resolve'); |
120 | 132 | return $event->getResolvedValue(); |
121 | 133 | } |
122 | 134 |
|
|
0 commit comments