-
-
Notifications
You must be signed in to change notification settings - Fork 466
Closed as not planned
Description
Describe the bug
When running a query or mutation that does not return an Eloquent model with a basic gate ability for the @can directive, it throws a DefinitionException stating Failed to find class ${graphQlType} in namespaces [...${modelNamspaces}] for directive @can..
Expected behavior/Solution
It should not fail without a model, but rather fallback to using any gates defined with Gate::define or similar methods.
Steps to reproduce
- Create a mutation or query using a custom resolver. That resolver should not return an Eloquent model.
- Define a basic gate in
app/Providers/AuthServiceProvider.phpusingGate::define. For example, it could be calledread. - Add a
@can(ability: 'read')directive to the operation in step 1. - Call the operation from a client.
Output/Logs
Click to expand
Entry truncated and tagged for readability.
[${timestamp}] local.ERROR: FFailed to find class ${graphQlType} in namespaces [...${modelNamspaces}] for directive @can. {...${context}, "exception":"[object] (Nuwave\\Lighthouse\\Exceptions\\DefinitionException(code: 0): ${message} at /usr/share/nginx/html/vendor/nuwave/lighthouse/src/Schema/Directives/BaseDirective.php:197)
[stacktrace]
...${stacktrace}
Lighthouse Version
5.61.0
Metadata
Metadata
Assignees
Labels
No labels