cancel
Showing results for 
Search instead for 
Did you mean: 

Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.

OrderBy is not working in neo4j-graphql-java lib

Hello,

I have declared following schema

type Person {
name: ID!
born: Int
actedIn: [Movie] @relation(name:"ACTED_IN")
}
type Movie {
title: ID!
released: Int
tagline: String
}
type Query {
person : [Person]
}

Running the following query
{
  person(filter: {name_starts_with: "L"}, orderBy: "born_asc", first: 5, offset: 2) {
    name
    born
    actedIn(first: 1) {
      title
    }
  }
}
Trying out the same example provided in https://github.com/neo4j-graphql/neo4j-graphql-java

String schema = getResourceFileAsString("neo4j.graphql");

GraphQLSchema schemagql = SchemaBuilder.buildSchema(schema);

Translator t = new Translator(schemagql);
List<Cypher> x = t.translate(query);

x.stream().forEach(c->System.out.println(" Test -->"+c.getQuery()));

I am getting following error

org.neo4j.graphql.InvalidQueryException: Validation error of type WrongType: argument 'orderBy' with value 'StringValue{value='born_asc'}' is not a valid '_PersonOrdering' - Expected AST type 'EnumValue' but was 'StringValue'. @ 'person'
at org.neo4j.graphql.Translator.translate(Translator.kt:35)
at org.neo4j.graphql.Translator.translate$default(Translator.kt:15)
at org.neo4j.graphql.Translator.translate(Translator.kt)
at com.graphql.DataFetcherDemo.main(DataFetcherDemo.java:97)

Am i doing something wrong?




1 REPLY 1

I have tried replacing string with enum and it is working

orderBy: "born_asc" replaced with
orderBy: born_asc