PHP code example of petecoop / laravel-actions-lighthouse

1. Go to this page and download the library: Download petecoop/laravel-actions-lighthouse 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/ */

    

petecoop / laravel-actions-lighthouse example snippets


use Petecoop\LaravelActionsLighthouse\AsGraphQL;

class SomeAction
{
    use AsAction, AsGraphQL;
}

[
    'namespaces' => [
        'queries' => [
            'App\\GraphQL\\Queries',
            'App\\Actions',
            'App\\Actions\\User',
        ],
    ]
]

class UpdateUserName
{
    use AsAction, AsGraphQL;

    public function handle(string $id, string $name)
    {
        //...
    }
}

class SomeAction
{
    use AsAction, AsGraphQL;

    public function handle(int $userId, string $name)
    {
        //...
    }

    public function asGraphQL($_, $args)
    {
        return $this->handle($args['id'], $args['name']);
    }
}

"directives" => ["App\\GraphQL\\Directives", "Petecoop\\LaravelActionsLighthouse"],

class UpdateUserName
{
    use AsAction, AsGraphQL;

    public function handle(string $id, string $name)
    {
        //...
    }

    public function rules(): array
    {
        return [
            'name' => ['