GraphQl LightHouse 条件不起作用
GraphQl LightHouse Where Condition not working
如何在查询中添加where
条件?
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 Look at scope
argument on @all directive and read about https://laravel.com/docs/8.x/eloquent#query-scopes。这就是你所需要的。 @where 指令只能在参数上传递。
你可以把 @where
with an optional Int
and add a orderBy
attribute with directive @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
}
如何在查询中添加where
条件?
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 Look at scope
argument on @all directive and read about https://laravel.com/docs/8.x/eloquent#query-scopes。这就是你所需要的。 @where 指令只能在参数上传递。
你可以把 @where
with an optional Int
and add a orderBy
attribute with directive @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
}