如何解决GraphQl LightHouse 条件不起作用
projects: [Project!]! @all @orderBy(column: "id",direction: DESC)
我想要:
projects: [Project!]! @all @orderBy(column: "id",direction: DESC) @where('parent_id','=',0)
解决方法
https://lighthouse-php.com/5/api-reference/directives.html#all 查看@all 指令上的scope
参数并阅读https://laravel.com/docs/8.x/eloquent#query-scopes。这就是你所需要的。 @where 指令只能在参数上传递。
您可以将 @where
与可选的 Int
放在一起,并添加带有指令 @orderBy
的 orderBy
属性,例如:
projects(
parent_id: Int @where(key: "parent_id")
orderBy: _@orderBy(columns: ["id"])
): [Project!]!
@all
,
Adding a where condition was too easy but was not clear in lighthouse docs.
projects(query: QueryCondition): [Project!]!
@all
@orderBy(column: "id",direction: DESC)
input QueryCondition {
parent_id: ID @eq
}
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。