1. Go to this page and download the library: Download mathsgod/light-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/ */
mathsgod / light-graphql example snippets
namespace Controllers;
use TheCodingMachine\GraphQLite\Annotations\Query;
class UserController
{
#[Query]
public function hello(): string
{
return 'world';
}
}
$server = new \Light\GraphQL\Server();
$server->getSchemaFactory()->addNamespace('Controllers');
// $request is a PSR-7 ServerRequestInterface
$response = $server->handle($request);