我使用的是"nuwave/lighthouse": "^4.14"
,并且有这个schema.graphql基于这个功能的文档:
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)
我已经在这里尝试过php artisan package:discover
,但没有帮助。
我从文档中知道vendornuwavelighthousesrcWhereConditionsWhereHasConditionsDirective.php
应该自动加载。
@spawnia,非常感谢你的图书馆。如果有任何关于我做错了什么的暗示,我将不胜感激。谢谢
来源https://lighthouse-php.com/4.14/eloquent/complex-where-conditions.html#setup:
这是一个实验功能,默认情况下不包含在Lighthouse中
将服务提供商添加到您的config/app.php
'providers' => [
NuwaveLighthouseWhereConditionsWhereConditionsServiceProvider::class,
],
安装依赖项mll-lab/graphql-php-scalars:
composer require mll-lab/graphql-php-scalars