Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

@with inherit @orderBy clause of original query #2473

Open
exodusanto opened this issue Nov 17, 2023 · 1 comment
Open

@with inherit @orderBy clause of original query #2473

exodusanto opened this issue Nov 17, 2023 · 1 comment
Labels
needs reproduction Failing test case needed

Comments

@exodusanto
Copy link
Contributor

exodusanto commented Nov 17, 2023

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

  1. Create a @hasMany relation on a model
  2. Add @orderBy to args
  3. Add @with to 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

@spawnia spawnia added the needs reproduction Failing test case needed label Dec 5, 2023
@spawnia
Copy link
Collaborator

spawnia commented Dec 5, 2023

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:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs reproduction Failing test case needed
Projects
None yet
Development

No branches or pull requests

2 participants