Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The basic library example doesn't work #269

Open
rullyalves opened this issue Feb 15, 2022 · 1 comment
Open

The basic library example doesn't work #269

rullyalves opened this issue Feb 15, 2022 · 1 comment
Labels
wait for answer Further information is requested

Comments

@rullyalves
Copy link

I tried this code example:

val schema =
"""
type Person {
name: ID!
age: Int
}
# Optional if you use generated queries
type Query {
person : [Person]
}"""

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.

@Andy2003
Copy link
Collaborator

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)
}

@Andy2003 Andy2003 added the wait for answer Further information is requested label Mar 25, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
wait for answer Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants