Hi,
when try:
users: [User!]! @paginate @can(if:"view any user")
I have error:
No class 'UserPaginator' was found for directive 'can'
When I delete @can, query works fine. My @can directive is fine, works with other queries and mutations. I expect error when I don't have permissions, and paginated data when permissions is granted.
Schema
extend type Query {
"Retrieve all users"
users: [User!]! @paginate @can(if:"view any user")
}
Output/Logs
Click to expand
No class 'UserPaginator' was found for directive 'can'
Environment
Lighthouse Version: 2.6.3
Laravel Version: 5.7
PHP Version: 7.1.9
Additional context
I use https://github.com/spatie/laravel-permission to manage privileges.
This happens because of the schema manipulation that @paginate does - when you look at the resulting user-facing schema, you will see the return type of the field gets renamed.
We have to adapt the logic of @can that guesses the Model name from the return type, probably by adding exceptions for the pagination suffixes ...Paginator and ...Connection. Preferrably integrated with the BaseDirective in a way that is reusable across mutliple directives.
I avoid this issue by specifying model with v3.0-alpha.1.
extend type Query {
"Retrieve all users"
users: [User!]! @paginate @can(if:"view any user" model: "User")
}
Most helpful comment
I avoid this issue by specifying
modelwith v3.0-alpha.1.