<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
veysiyildiz / module-graphql-performance example snippets
use Sterk\GraphQlPerformance\Model\DataLoader\ProductDataLoader;
class ProductResolver implements ResolverInterface
{
public function __construct(
private readonly ProductDataLoader $dataLoader
) {}
public function resolve(
Field $field,
$context,
ResolveInfo $info,
array $value = null,
array $args = null
) {
return $this->dataLoader->load($args['id']);
}
}
use Sterk\GraphQlPerformance\Model\DataLoader\BatchDataLoader;
class CustomDataLoader extends BatchDataLoader
{
protected function loadFromDatabase(array $ids): array
{
// Implement batch loading logic
}
protected function generateCacheKey(string $id): string
{
return "custom_entity_{$id}";
}
}
use Sterk\GraphQlPerformance\Model\Cache\TagManager;
class CustomResolver
{
public function __construct(
private readonly TagManager $tagManager
) {}
public function resolve($field)
{
$tags = $this->tagManager->getEntityTags('custom_entity', $id);
// Use tags for cache operations
}
}