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

It is an enum not a string. GraphQL used to be more lenient before allowing strings also in places for Enums,

just remove the double quotes around 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.