`@with` inherit `@orderBy` clause of original query
Nobody has claimed this yet.
- Dominant language
- PHP
- Stars
- 3.5k
- Forks
- 468
- Avg merge
- 3h 9m
- Merged PRs (30d)
- 2
Description
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
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in src/Schema/Directives/RelationDirectiveHelpers.php at the builder code linked in the report, and reproduce the @hasMany, @orderBy, and @with combination described in the steps. Check how the related load inherits the original query ordering. Done means the generated related query no longer contains the original orderBy clause and the reported relation query succeeds.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- graphql, laravel, php
- Domain
- api, backend, databases
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100