Youshido\GraphQL\Execution\Processor::collectResult PHP Method

collectResult() private method

private collectResult ( Youshido\GraphQL\Field\FieldInterface $field, AbstractObjectType $type, $ast, $resolvedValue )
$field Youshido\GraphQL\Field\FieldInterface
$type Youshido\GraphQL\Type\Object\AbstractObjectType
    private function collectResult(FieldInterface $field, AbstractObjectType $type, $ast, $resolvedValue)
    {
        /** @var AstQuery $ast */
        $result = [];
        foreach ($ast->getFields() as $astField) {
            switch (true) {
                case $astField instanceof TypedFragmentReference:
                    $astName = $astField->getTypeName();
                    $typeName = $type->getName();
                    if ($typeName !== $astName) {
                        foreach ($type->getInterfaces() as $interface) {
                            if ($interface->getName() === $astName) {
                                $result = array_merge($result, $this->collectResult($field, $type, $astField, $resolvedValue));
                                break;
                            }
                        }
                        continue;
                    }
                    $result = array_merge($result, $this->collectResult($field, $type, $astField, $resolvedValue));
                    break;
                case $astField instanceof FragmentReference:
                    $astFragment = $this->executionContext->getRequest()->getFragment($astField->getName());
                    $astFragmentModel = $astFragment->getModel();
                    $typeName = $type->getName();
                    if ($typeName !== $astFragmentModel) {
                        foreach ($type->getInterfaces() as $interface) {
                            if ($interface->getName() === $astFragmentModel) {
                                $result = array_merge($result, $this->collectResult($field, $type, $astFragment, $resolvedValue));
                                break;
                            }
                        }
                        continue;
                    }
                    $result = array_merge($result, $this->collectResult($field, $type, $astFragment, $resolvedValue));
                    break;
                default:
                    $result[$this->getAlias($astField)] = $this->resolveField($field, $astField, $resolvedValue, true);
            }
        }
        return $result;
    }