Neo4j-graphql-js: Specify Order By

Created on 6 Apr 2018  路  14Comments  路  Source: neo4j-graphql/neo4j-graphql-js

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?

All 14 comments

Any progress on this?

@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 :)

@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
    }
  }
}

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")

@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!

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

@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

@appinteractive any progress on this?

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

@johnymontana yeah any progress? Happy New Year by the way :) 馃帀馃コ

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

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

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

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?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

purplemana picture purplemana  路  3Comments

bebbi picture bebbi  路  3Comments

bebbi picture bebbi  路  6Comments

robmurtagh picture robmurtagh  路  3Comments

AdrienLemaire picture AdrienLemaire  路  4Comments