You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
p3(name:String): Person @cypher(statement:"MATCH (p:Person) WHERE p.name = name RETURN p LIMIT 1")
18
23
}
19
24
"""
20
25
21
26
@Test
22
-
funrenderCypherDirective() {
27
+
funrenderCypherFieldDirective() {
23
28
24
-
val expected ="""MATCH (person:Person) RETURN person { name:apoc.cypher.runFirstColumnSingle('WITH ${"$"}this AS this RETURN this.name',{this:person}) } AS person"""
29
+
val expected ="""MATCH (person:Person) RETURN person { name:apoc.cypher.runFirstColumnSingle('WITH ${"$"}this AS this RETURN this.name',{this:person}) } AS person"""
val expected ="""MATCH (person:Person) RETURN person { age:apoc.cypher.runFirstColumnMany('WITH ${"$"}this AS this,${'$'}mult AS mult RETURN this.age * mult as age',{this:person,mult:${'$'}personMult}) } AS person"""
37
+
val expected ="""MATCH (person:Person) RETURN person { age:apoc.cypher.runFirstColumnMany('WITH ${"$"}this AS this,${'$'}mult AS mult RETURN this.age * mult as age',{this:person,mult:${'$'}personMult}) } AS person"""
33
38
val query ="""{ person { age }}"""
34
39
assertQuery(query, expected, mapOf("personMult" to 13))
35
40
}
36
41
37
42
@Test
38
-
funrenderCypherDirectiveWithParams() {
43
+
funrenderCypherFieldDirectiveWithParams() {
39
44
40
-
val expected ="""MATCH (person:Person) RETURN person { age:apoc.cypher.runFirstColumnMany('WITH ${"$"}this AS this,${'$'}mult AS mult RETURN this.age * mult as age',{this:person,mult:${'$'}personMult}) } AS person"""
45
+
val expected ="""MATCH (person:Person) RETURN person { age:apoc.cypher.runFirstColumnMany('WITH ${"$"}this AS this,${'$'}mult AS mult RETURN this.age * mult as age',{this:person,mult:${'$'}personMult}) } AS person"""
41
46
val query ="""{ person { age(mult:25) }}"""
42
47
assertQuery(query, expected, mapOf("personMult" to 25L))
val result =Translator(SchemaBuilder.buildSchema(schema)).translate(query).first()
47
-
assertEquals(expected, result.query)
48
-
assertTrue("${params} IN ${result.params}", result.params.entries.containsAll(params.entries))
50
+
@Test
51
+
funrenderCypherQueryDirective() {
52
+
val expected ="""UNWIND apoc.cypher.runFirstColumnMany('MATCH (p:Person) RETURN p',{}) AS p2 RETURN p2 { .id } AS p2"""
53
+
val query ="""{ p2 { id }}"""
54
+
assertQuery(query, expected, emptyMap())
55
+
}
56
+
@Test
57
+
funrenderCypherQueryDirectiveParams() {
58
+
val expected ="""UNWIND apoc.cypher.runFirstColumnSingle('WITH ${'$'}name AS name MATCH (p:Person) WHERE p.name = name RETURN p LIMIT 1',{name:${'$'}p3Name}) AS p3 RETURN p3 { .id } AS p3"""
59
+
val query ="""{ p3(name:"Jane") { id }}"""
60
+
assertQuery(query, expected, mapOf("p3Name" to "Jane"))
61
+
}
62
+
@Test
63
+
funrenderCypherQueryDirectiveParamsArgs() {
64
+
val expected ="""UNWIND apoc.cypher.runFirstColumnSingle('WITH ${'$'}name AS name MATCH (p:Person) WHERE p.name = name RETURN p LIMIT 1',{name:${'$'}pname}) AS p3 RETURN p3 { .id } AS p3"""
65
+
val query ="""query(${'$'}pname:String) { p3(name:${'$'}pname) { id }}"""
66
+
assertQuery(query, expected, mapOf("pname" to VariableReference("pname")))
val result =Translator(SchemaBuilder.buildSchema(schema)).translate(query).first()
76
+
assertEquals(expected, result.query)
77
+
assertTrue("${params} IN ${result.params}", params.all { val v=result.params[it.key]; when (v) { isNode-> v.isEqualTo(it.value asNode) else-> v == it.value}})
0 commit comments