mlab817 / lighthouse-graphql-permission
This package is abandoned and no longer maintained.
No replacement package was suggested.
Add GraphQL types and mutations for spatie/laravel-permission
1.16.0
2020-12-20 13:00 UTC
Requires
- php: ^7.3|^8.0
- nuwave/lighthouse: ^4.18
- spatie/laravel-permission: ^3.18
Requires (Dev)
- orchestra/testbench: ^6.6
- phpunit/phpunit: ^9.0
README
A composer package for adding GraphQL Types to support spatie/laravel-permission.
Installation
To install the package, run the following command in your project directory:
composer require mlab817/lighthouse-graphql-permission
The command will also install the dependencies of the package: spatie/laravel-permission
and nuwave/lighthouse
.
Set up
- Proceed with setting up spatie/laravel-permission as usual. Add the
Spatie Permission Service Provider
in theconfig/app.php
file. Also add theHasRoles
trait in your User model. Do not forget to publish and run the migration. If you need to modify the config of the package, you may also do so by publishing the package's config file. - Add the
\Mlab817\LighthouseGraphQLPermission\Providers\LighthouseGraphQLPermissionServiceProvider::class
in theconfig/app.php
file. This will add the service provider of the package to your app. Then, publish theconfig
andschema
files of the package by runningphp artisan vendor:publish
and selecting the relevant options. - You can now use the package.
Schema
type Permission { id: ID name: String guard_name: String } type Role { id: ID name: String guard_name: String } input CreateRoleInput { name: String! } input CreatePermissionInput { name: String! } input GivePermissionToUserInput { user_id: ID! permission: String! } input AssignRoleInput { user_id: ID! role: String! } input GivePermissionToRoleInput { user_id: ID! permission: String! } input RevokePermissionToUserInput { user_id: ID! permission: String! } input RevokePermissionToRoleInput { role: String! permission: String! } type Mutation { createRole(input: CreateRoleInput!): Role! createPermission(input: CreatePermissionInput!): Permission! givePermissionToUser(input: GivePermissionToUserInput!): String assignRole(input: AssignRoleInput!): User! givePermissionToRole(input: GivePermissionToRoleInput!): String revokePermissionToUser(input: RevokePermissionToUserInput!): String revokePermissionToRole(input: RevokePermissionToRoleInput!): String }