Skip to content

Commit

Permalink
Merge pull request #78 from Pirokiko/master
Browse files Browse the repository at this point in the history
Support for Symfony 4.3 EventDispatcher->dispatch definition
  • Loading branch information
viniychuk committed Jul 31, 2019
2 parents e74a544 + f89b4be commit 5f192e7
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions Execution/Processor.php
Expand Up @@ -4,6 +4,7 @@

use Psr\Log\LoggerInterface;
use Symfony\Component\DependencyInjection\ContainerAwareInterface;
use Symfony\Component\HttpKernel\Kernel;
use Youshido\GraphQL\Execution\Context\ExecutionContextInterface;
use Youshido\GraphQL\Execution\Processor as BaseProcessor;
use Youshido\GraphQL\Execution\ResolveInfo;
Expand Down Expand Up @@ -74,14 +75,25 @@ protected function resolveQuery(Query $query)
return parent::resolveQuery($query);
}

private function dispatchResolveEvent(ResolveEvent $event, $name){
$major = Kernel::MAJOR_VERSION;
$minor = Kernel::MINOR_VERSION;

if($major > 4 || ($major === 4 && $minor >= 3)){
$this->eventDispatcher->dispatch($event, $name);
}else{
$this->eventDispatcher->dispatch($name, $event);
}
}

protected function doResolve(FieldInterface $field, AstFieldInterface $ast, $parentValue = null)
{
/** @var AstQuery|AstField $ast */
$arguments = $this->parseArgumentsValues($field, $ast);
$astFields = $ast instanceof AstQuery ? $ast->getFields() : [];

$event = new ResolveEvent($field, $astFields);
$this->eventDispatcher->dispatch('graphql.pre_resolve', $event);
$this->dispatchResolveEvent($event, 'graphql.pre_resolve');

$resolveInfo = $this->createResolveInfo($field, $astFields);
$this->assertClientHasFieldAccess($resolveInfo);
Expand Down Expand Up @@ -116,7 +128,7 @@ protected function doResolve(FieldInterface $field, AstFieldInterface $ast, $par
}

$event = new ResolveEvent($field, $astFields, $result);
$this->eventDispatcher->dispatch('graphql.post_resolve', $event);
$this->dispatchResolveEvent($event, 'graphql.post_resolve');
return $event->getResolvedValue();
}

Expand Down

0 comments on commit 5f192e7

Please sign in to comment.