lighthouse
lighthouse copied to clipboard
`@with` inherit `@orderBy` clause of original query
Describe the bug
Seems like the @with inherit @orderBy clause of original query, so if the column doesn't exists also in relation it will fail the query
Maybe the solution is to only add ->reorder() on the builder
Expected behavior/Solution
The ->load should not contain orderBy clause
Steps to reproduce
- Create a
@hasManyrelation on a model - Add
@orderByto args - Add
@withto another relation on the same model
Output/Logs
Click to expand
select
`users`.*,
`circles`.`user_id` as `pivot_user_id`,
`circles`.`peer_id` as `pivot_peer_id`,
`circles`.`created_at` as `pivot_created_at`,
`circles`.`updated_at` as `pivot_updated_at`
from
`users`
inner join `circles` on `users`.`id` = `circles`.`peer_id`
where
`circles`.`user_id` in (31)
order by
`created_at` desc
Lighthouse Version
v6.22.0
Could you add a failing test case? Not exactly sure where best to put it since multiple directives are concerned, feel free to choose among WithDirectiveTest, OrderByDirectiveDBTest or HasManyDirectiveTest: