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

Nested sorting #194

Open
ValentinVignal opened this issue Oct 23, 2023 · 5 comments
Open

Nested sorting #194

ValentinVignal opened this issue Oct 23, 2023 · 5 comments
Labels
enhancement New feature or request

Comments

@ValentinVignal
Copy link
Contributor

ValentinVignal commented Oct 23, 2023

Is your feature request related to a problem? Please describe.

There were some issues on https://github.com/doug-martin/nestjs-query about being able to sort by nested fields:

which could be super helpful. I would like to be able to sort a list of Todos by their linked project name:

query myTodos {
  todos(
    # Sort by project name here
  ) {
    id # ID!
    name  # String!
    completed # Boolean!
    project {  # Project!
      id # ID!
      name # String!
    }
  }
}

In my case, I only have the need for "one-to-one" or "one-to-many" relationships (1 todo won't be linked to multiple projects)

Have you read the Contributing Guidelines?

Yes

Describe the solution you'd like

The solution offered doug-martin/nestjs-query#559 (comment) was not too bad:

TodoSortFields {
  id
  name
  project__id
  project__name
}

Describe alternatives you've considered
Writing my own custom resolver where I can implement my own sorting.

@ValentinVignal ValentinVignal added the enhancement New feature or request label Oct 23, 2023
@dvins
Copy link

dvins commented Nov 19, 2023

Separating the table from the column using a . might be better syntax.

@ValentinVignal
Copy link
Contributor Author

Separating the table from the column using a . might be better syntax.

I don't think that possible, see this comment doug-martin/nestjs-query#559 (comment)

@dvins
Copy link

dvins commented Nov 20, 2023

Thanks for pointing out @ValentinVignal, the double underscore makes sense.

@dvins
Copy link

dvins commented Jul 13, 2024

By chance @TriPSs have you been able to look at this or have any insights on a preferred approach?

@TriPSs
Copy link
Owner

TriPSs commented Jul 15, 2024

Have not looked at it, __ think it's good, changes of that colliding with other fields should be pretty low.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants