0

我想在我的所有查询和突变中添加类似的内容

type Query @middleware(checks: ["moduleCheck", "moduleScope"]){
  //
}

有没有办法在全球范围内运行中间件?

我可以将它添加到$middleware变量中,Http\Kernal.php但是我的中间件不会响应所需的查询设置为null,这会引发不同的错误。

4

1 回答 1

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,
    ],
于 2020-08-10T08:42:09.840 回答