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

resolveList() protected method

protected resolveList ( Youshido\GraphQL\Field\FieldInterface $field, Youshido\GraphQL\Parser\Ast\Interfaces\FieldInterface $ast, $parentValue )
$field Youshido\GraphQL\Field\FieldInterface
$ast Youshido\GraphQL\Parser\Ast\Interfaces\FieldInterface
    protected function resolveList(FieldInterface $field, AstFieldInterface $ast, $parentValue)
    {
        /** @var AstQuery $ast */
        $resolvedValue = $this->doResolve($field, $ast, $parentValue);
        $this->resolveValidator->assertValidResolvedValueForField($field, $resolvedValue);
        if (null === $resolvedValue) {
            return null;
        }
        /** @var AbstractListType $type */
        $type = $field->getType()->getNullableType();
        $itemType = $type->getNamedType();
        $fakeAst = clone $ast;
        if ($fakeAst instanceof AstQuery) {
            $fakeAst->setArguments([]);
        }
        $fakeField = new Field(['name' => $field->getName(), 'type' => $itemType]);
        $result = [];
        foreach ($resolvedValue as $resolvedValueItem) {
            try {
                $fakeField->getConfig()->set('resolve', function () use($resolvedValueItem) {
                    return $resolvedValueItem;
                });
                switch ($itemType->getNullableType()->getKind()) {
                    case TypeMap::KIND_ENUM:
                    case TypeMap::KIND_SCALAR:
                        $value = $this->resolveScalar($fakeField, $fakeAst, $resolvedValueItem);
                        break;
                    case TypeMap::KIND_OBJECT:
                        $value = $this->resolveObject($fakeField, $fakeAst, $resolvedValueItem);
                        break;
                    case TypeMap::KIND_UNION:
                    case TypeMap::KIND_INTERFACE:
                        $value = $this->resolveComposite($fakeField, $fakeAst, $resolvedValueItem);
                        break;
                    default:
                        $value = null;
                }
            } catch (\Exception $e) {
                $this->executionContext->addError($e);
                $value = null;
            }
            $result[] = $value;
        }
        return $result;
    }