<?php
/**
 * Created by PhpStorm.
 * User: blaise
 * Date: 25/05/18
 * Time: 18:32.
 */

namespace Datatourisme\Api\Processor;

use Datatourisme\Api\Schema\Type\Object\LangStringType;
use Youshido\GraphQL\Field\FieldInterface;
use Youshido\GraphQL\Parser\Ast\Interfaces\FieldInterface as AstFieldInterface;

/**
 * Class Processor.
 */
class Processor extends \Youshido\GraphQL\Execution\Processor
{
    protected function resolveObject(FieldInterface $field, AstFieldInterface $ast, $parentValue = null, $fromObject = false)
    {
        // hack to handle legacy langstring behavior
        // will be deprecated in 2.0
        if ($field->getType() instanceof LangStringType && !count($ast->getFields())) {
            return $parentValue;
        }

        return parent::resolveObject($field, $ast, $parentValue, $fromObject); // TODO: Change the autogenerated stub
    }
}
