如何修复 Laravel Lighthouse 中的 "No directive found for `whereHasConditions`"?

How can I fix "No directive found for `whereHasConditions`" in Laravel Lighthouse?

我正在使用 "nuwave/lighthouse": "^4.14" 并且 schema.graphql 基于 the docs of this feature:

type Query {
    # ...
    postsWithUnseenComments(orderBy: _ @orderBy(columns: ["id", "created_at"], order: ASC), hasComments: _ @whereHasConditions(columns: ["user_id", "seen_at"])): [Post!]! @paginate(defaultCount: 20) @cache
}

我得到这个错误:

No directive found for `whereHasConditions` {"exception":"[object] (Nuwave\Lighthouse\Exceptions\DirectiveException(code: 0): No directive found for `whereHasConditions` at C:\code\myproject\vendor\
uwave\lighthouse\src\Schema\Factories\DirectiveFactory.php:91)

我已经从 here 尝试了 php artisan package:discover,但没有帮助。

我从 the docs 得知 vendor\nuwave\lighthouse\src\WhereConditions\WhereHasConditionsDirective.php 应该自动加载。

@spawnia,非常感谢您的精彩图书馆。对于我做错了什么的任何提示,我将不胜感激。谢谢。

来自https://lighthouse-php.com/4.14/eloquent/complex-where-conditions.html#setup

这是一项实验性功能,默认情况下不包含在 Lighthouse 中。

将服务提供商添加到您的 config/app.php

'providers' => [
    \Nuwave\Lighthouse\WhereConditions\WhereConditionsServiceProvider::class,
],

安装依赖[=​​14=]:

composer require mll-lab/graphql-php-scalars