1. Go to this page and download the library: Download reydajp/cake-graphql 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/ */
reydajp / cake-graphql example snippets
// src/Application.php
public function bootstrap(): void
{
parent::bootstrap();
$this->addPlugin('CakeGraphQL');
}
declare(strict_types=1);
namespace App\Graphql;
use Cake\ORM\Locator\LocatorAwareTrait;
use TheCodingMachine\GraphQLite\Annotations\Query;
final class UsersQuery
{
use LocatorAwareTrait;
#[Query]
public function users(int $limit = 50): array
{
$limit = max(1, min($limit, 100));
return $this->fetchTable('Users')->find()->limit($limit)->all()->toList();
}
}
use App\Model\Entity\User;
use TheCodingMachine\GraphQLite\Annotations\InjectUser;
use TheCodingMachine\GraphQLite\Annotations\Query;
final class UsersQuery
{
#[Query]
public function me(#[InjectUser] ?User $user): ?User
{
return $user;
}
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.