Open rullyalves opened 2 years ago
I cant see any problem with your example:
package demo
import org.neo4j.graphql.QueryContext
import org.neo4j.graphql.SchemaBuilder
import org.neo4j.graphql.Translator
fun main() {
val idl = """
type Person {
name: ID!
age: Int
}
# Optional if you use generated queries
type Query {
person : [Person]
}
""".trimIndent()
val query = """ query { person { age } } """
val schema = SchemaBuilder.buildSchema(idl)
val ctx = QueryContext()
val (cypher) = Translator(schema).translate(query, mapOf(), ctx).first()
// prints: MATCH (person:Person) RETURN person { .age } AS person
println(cypher)
}
I tried this code example:
val schema = """ type Person { name: ID! age: Int }
Optional if you use generated queries
val query = """ quero { person { age } } """
val schema = SchemaBuilder.buildSchema(idl) val ctx = QueryContext() val (cypher, params) = Translator(schema).translate(query, mapOf(), ctx)
// generated Cypher cypher == "MATCH (p:Person) WHERE p.name = $pName RETURN p {.age} as p"
but i get an error about GraphQLDefaultValueArgument, I would like to know if I am doing something wrong and if this library can be used solely to translate graphql queries into cypher queries.