cancel
Showing results for 
Search instead for 
Did you mean: 

OrderBy is not working in neo4j-graphql-java lib

harik
Node

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

harik
Node

I have tried replacing string with enum and it is working

orderBy: "born_asc" replaced with
orderBy: born_asc

 

Nodes 2022
Nodes
NODES 2022, Neo4j Online Education Summit

On November 16 and 17 for 24 hours across all timezones, you’ll learn about best practices for beginners and experts alike.