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

Support for deep-sorting #64

Open
Andy2003 opened this issue Sep 25, 2019 · 4 comments
Open

Support for deep-sorting #64

Andy2003 opened this issue Sep 25, 2019 · 4 comments
Labels
enhancement New feature or request

Comments

@Andy2003
Copy link
Collaborator

Given the Schema:

type Movie {
  title: String
  publishedBy: Publisher @relation(name: "PUBLISHED_BY", direction: OUT)
}

type Publisher {
  name: ID!
}

The augmentation would be:

type Query {
  movie(sort: [_MovieSorting!]): [Movie!]!
}
enum SortDirection{
  asc,
  desc,
}

input _MovieSorting {
  title: SortDirection
  publishedBy: [_PublisherSorting!]
}

input _PublisherSorting {
  name: SortDirection
}

So a user can get all movies ordered by Publisher.name and title by calling

query {
  movie(sort: [{publishedBy: [{name: desc}]}, {title: asc}]) {
    title
  }
}

which results in this query

MATCH (m:Movie)
WITH m
  ORDER BY head([(m)-[:PUBLISHED_BY]->(p:Publisher) | p.name]) DESC, m.name ASC
RETURN m{.title}

This sorting should be possible for all 1..1 relations.
This is related to #3 since the input of sorting will no longer be an enum.

@jexp
Copy link
Contributor

jexp commented Sep 25, 2019

Break it up into 2 steps

  1. input type for sorting
  2. optionally deep sorting

question: how do we manage the backwards compatibility if any.

@Andy2003
Copy link
Collaborator Author

we can generate 2 arguments:

  1. deprecated enum
  2. new input field

@jexp
Copy link
Contributor

jexp commented Sep 25, 2019

Would need to align with neo4j-graphql-js

perhaps we can call the new field: sortBy or sort

/cc @johnymontana

@Andy2003
Copy link
Collaborator Author

Break it up into 2 steps

  1. input type for sorting
  2. optionally deep sorting

for 1. I created issue #196

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

2 participants