我想在所有查询和变异中添加类似的内容
type Query @middleware(checks: ["moduleCheck", "moduleScope"]){
//
}
是否可以在全球范围内运行中间件?
我可以将其添加到$middleware
中的Http\Kernal.php
变量中,但是随后我的中间件将不会响应,并将必需的查询设置为null
,这会引发另一个错误。
答案 0 :(得分:0)
您可以像这样尝试将其放入lighthouse.php中的中间件配置中
'middleware' => [
\Nuwave\Lighthouse\Support\Http\Middleware\AcceptJson::class,
// Logs in a user if they are authenticated. In contrast to Laravel's 'auth'
// middleware, this delegates auth and permission checks to the field level.
\Nuwave\Lighthouse\Support\Http\Middleware\AttemptAuthentication::class,
\App\Http\Middleware\YourMiddlewareGoesHere::class,
],