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 @hasMany relation on a model
Add @orderBy to args
Add @with to another relation on the same model
Output/Logs
Click to expand
```sql
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:
Describe the bug
Seems like the
@with
inherit@orderBy
clause of original query, so if thecolumn
doesn't exists also in relation it will fail the queryMaybe the solution is to only add
->reorder()
on the builderExpected behavior/Solution
The
->load
should not containorderBy
clauseSteps to reproduce
@hasMany
relation on a model@orderBy
to args@with
to another relation on the same modelOutput/Logs
Click to expand
```sql 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 ```