cboxdk/lighthouse-spatie-permissions

Adds types and mutations to lighthouse-php GraphQL for spatie/laravel-permission


README

Latest Version on Packagist GitHub Tests Action Status GitHub Code Style Action Status Total Downloads

This package is created for internal use with heavy inspiration from mlab817/lighthouse-graphql-permission.

Installation

You can install the package via composer:

composer require cboxdk/lighthouse-spatie-permissions

You can publish the config file with:

php artisan vendor:publish --tag="lighthouse-spatie-permissions-config"

This is the contents of the published config file:

return [
    /*
     * Define where the schema will be stored
     */
    'schema' => null,
    /*
     * Determine the guard to use as default guard_name when creating roles and permissions
     * Defaults to api
     */
    'guard' => env('LIGHTHOUSE_PERMISSION_GUARD', 'api'),
    /*
     * Restrict mutations to specific role
     */
    'restrict' => [
        'role' => env('LIGHTHOUSE_PERMISSION_RESTRICT_MUTATIONS','admin')
    ],

    'users' => [
        'table' => env('LIGHTHOUSE_PERMISSION_USERS_TABLE', 'users'),
    ],
];

Optionally, you can publish the views using

php artisan vendor:publish --tag="lighthouse-spatie-permissions-views"

Usage

The graphql schema is added to lighthouse. You may change it or use as is.

Testing

composer test

Changelog

Please see CHANGELOG for more information on what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security Vulnerabilities

Please review our security policy on how to report security vulnerabilities.

Credits

License

The MIT License (MIT). Please see License File for more information.