1. Go to this page and download the library: Download overblog/dataloader-bundle library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
overblog / dataloader-bundle example snippets
class AppKernel extends Kernel
{
public function registerBundles()
{
$bundles = [
// ...
new Overblog\DataLoaderBundle\OverblogDataLoaderBundle(),
];
// ...
}
// ...
}
namespace AppBundle\GraphQL\Loader;
use AppBundle\Entity\Repository\ShipRepository;
use GraphQL\Executor\Promise\PromiseAdapter;
class ShipLoader
{
private $promiseAdapter;
private $repository;
public function __construct(PromiseAdapter $promiseAdapter, ShipRepository $repository)
{
$this->promiseAdapter = $promiseAdapter;
$this->repository = $repository;
}
public function all(array $shipsIDs)
{
$qb = $this->repository->createQueryBuilder('s');
$qb->add('where', $qb->expr()->in('s.id', ':ids'));
$qb->setParameter('ids', $shipsIDs);
$ships = $qb->getQuery()->getResult();
return $this->promiseAdapter->all($ships);
}
}
public function resolveShip($shipID)
{
$promise = $this->container->get('ships_loader')->load($shipID);
return $promise;
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.