neo4j-graphql-java
neo4j-graphql-java copied to clipboard
Support for deep-sorting
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.
Break it up into 2 steps
- input type for sorting
- optionally deep sorting
question: how do we manage the backwards compatibility if any.
we can generate 2 arguments:
- deprecated enum
- new input field
Would need to align with neo4j-graphql-js
perhaps we can call the new field: sortBy or sort
/cc @johnymontana
Break it up into 2 steps
- input type for sorting
- optionally deep sorting
for 1. I created issue #196