<?php

declare(strict_types=1);

namespace KupShop\GraphQLBundle\ApiAdmin\Types\Return\Response;

use KupShop\GraphQLBundle\ApiAdmin\Types\MutateResponse;
use KupShop\GraphQLBundle\ApiAdmin\Types\Return\ReturnDto;
use TheCodingMachine\GraphQLite\Annotations\Field;
use TheCodingMachine\GraphQLite\Annotations\Type;

#[Type]
class ReturnMutateResponse extends MutateResponse
{
    public function __construct(
        bool $result,
        private readonly \Closure $returnLoader,
    ) {
        parent::__construct($result);
    }

    #[Field(description: 'Vratka.')]
    public function getReturn(): ReturnDto
    {
        return ($this->returnLoader)();
    }
}
