Neo4j-graphql-java translator

Hi all,

I'm trying to use neo4j-graphql-java to translate graphql queries into cypher statements, using the movie example.

My schema.graphqls:
type Query {
hello: String!
person(name: String): Person
}

type Movie {
title: String!
released: Int
tagline: String
}

type Person {
name: String!
born: Int
movies: [Movie]
}

My code to do the translation:
String query = "{\n" +
" person(name: $personName) {\n" +
" name\n" +
" born\n" +
" }\n" +
"}";
Translator translator = new Translator(schema);
Map<String, String> params = new HashMap<>();
params.put("personName", "Tom Hanks");
List<Translator.Cypher> cyphers = translator.translate(query, params);
Driver driver = GraphDatabase.driver("bolt://localhost:7687", AuthTokens.basic("neo4j", "secret"));
StatementResult result = driver.session().run(cyphers.get(0).getQuery());

The translation (Cypher object) is:

MATCH (person:Person) WHERE person.name = $personName RETURN person { .name,.born } AS person

and I can see there's params in it: "personName" -> "Tom Hanks"

However the result of the execution is empty, it's actually complaining about not finding params:
"Expected parameter(s): personName"

What did I miss? Could anyone please explain what's the common practice to do this?

Thanks!

You Wu

Use List<Translator.Cypher> cypherList = translator.translate(query);.
Parameters are resolved from the query itself and doesn't need to be passed with the query to the query translator.