How to add a where
condition in query?
projects: [Project!]! @all @orderBy(column: "id", direction: DESC)
I'd like to have:
projects: [Project!]! @all @orderBy(column: "id", direction: DESC) @where('parent_id','=',0)
How to add a where
condition in query?
projects: [Project!]! @all @orderBy(column: "id", direction: DESC)
I'd like to have:
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. This is what you need. @where directive can be passed only on arguments.
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
}