Skip to content
This repository was archived by the owner on Sep 3, 2021. It is now read-only.

Specify Order By #47

Closed
zacksayenko opened this issue Apr 6, 2018 · 14 comments
Closed

Specify Order By #47

zacksayenko opened this issue Apr 6, 2018 · 14 comments

Comments

@zacksayenko
Copy link

Is there a way to specify Order By for arrays of nodes?
I see the current generated cypher queries do not have Order By specified and it just returns the list of nodes in a default order, is there a way to change it?

@appinteractive
Copy link

Any progress on this?

@appinteractive
Copy link

@johnymontana is any help needed or @zacksayenko is there any workaround we can use for now? Its really important for me as I'm in the middle of a product launch :)

@johnymontana
Copy link
Contributor

@appinteractive have you tried the orderBy field argument that is added as part of the schema augmentation process? There's an example in the docs here, but the basic idea is we add an orderBy field argument and generate an ordering enum type for each based on the scalar fields for that type. For example:

{
  Company(orderBy:name_desc) {
    name
    speakers(orderBy:name_desc) {
      name
    }
  }
}

@appinteractive
Copy link

appinteractive commented Oct 30, 2018

Yeah @johnymontana but I always get the default order. Im ordering the results by creation date which I saved as string. Could this be the problem? Do I have to do any atitional stuff on the database level?

grafik

Here the query that was run:

MATCH (user:User {slug:$slug,deleted:$deleted,disabled:$disabled}) 
RETURN user { .name ,contributions: [(user)-[:WROTE]->(user_contributions:Post{}) | user_contributions { .createdAt }][0..10] } AS user SKIP $offset
{ offset: 0,
  first: -1,
  slug: 'sabine-klee',
  deleted: false,
  disabled: false,
  '1_first': 10,
  '1_offset': 0,
  '1_orderBy': 'createdAt_desc' }

I'm trying to avoid timestamps as no one can read them

By the way - this is my relation on the User type:
contributions: [Post]! @relation(name: "WROTE", direction: "OUT")

@johnymontana
Copy link
Contributor

@appinteractive after looking into this I realized we've only implemented ordering at the top level operation and not nested selections. This is a bug as the orderBy argument is added, but ordering is not actually implemented in the generated query. We'll fix this soon!

@appinteractive
Copy link

@johnymontana thanks! Can you specifiy "soon" a bit more? Just want to know as we depend on that feature in our project.

@johnymontana
Copy link
Contributor

@appinteractive we've prioritized it for the current sprint. I'll work on moving all issues into a Github project board so we have better visibility of the roadmap and current progress

@smkhalsa
Copy link
Contributor

@appinteractive any progress on this?

@GeoffThorpeFT
Copy link

@johnymontana Can you give us any progress update on the nested orderBy?

@appinteractive
Copy link

@johnymontana yeah any progress? Happy New Year by the way :) 🎉🥳

@GeoffThorpeFT
Copy link

@johnymontana. Its been about a month since the last chase up .... any progress re a fix to this issue?

@johnymontana
Copy link
Contributor

The fix for nested ordering should be dropping this week - sorry for the delay on this.

@johnymontana
Copy link
Contributor

The fix for this is now available in v2.3.0 - please test and let us know how it works.

@jonasdumas
Copy link

The problem is still there. We've nested items :

Post(ttuid: $postTtuid){
      comments(orderBy: created_at_desc){
          ...Comment
      }
  }

Whetever field we define for orderBy to order our comments, it doesn't change the order.

We've version neo4j-graphql-js 2.11.0

Any idea why?

# for free to subscribe to this conversation on GitHub. Already have an account? #.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants