@@ -3,6 +3,7 @@ package org.neo4j.graphql
33import org.antlr.v4.runtime.misc.ParseCancellationException
44import org.junit.Assert.assertEquals
55import org.junit.Assert.assertTrue
6+ import org.junit.Ignore
67import org.junit.Test
78
89class TranslatorTest {
@@ -51,49 +52,60 @@ class TranslatorTest {
5152 @Test
5253 fun nestedQuery () {
5354 val query = " { person { name age livesIn { name } } } "
54- assertQuery(query, " MATCH (person:Person) RETURN person { .name,.age,livesIn:[(person)-[:LIVES_IN]->(livesIn :Location) | livesIn { .name }][0] } AS person" )
55+ assertQuery(query, " MATCH (person:Person) RETURN person { .name,.age,livesIn:[(person)-[:LIVES_IN]->(personLivesIn :Location) | personLivesIn { .name }][0] } AS person" )
5556 }
5657
5758 @Test
5859 fun nestedQuery2ndHop () {
5960 val query = " { person { name age livesIn { name founded {name}} } } "
60- assertQuery(query, " MATCH (person:Person) RETURN person { .name,.age,livesIn:[(person)-[:LIVES_IN]->(livesIn :Location) | livesIn { .name,founded:[(livesIn )<-[:FOUNDED]-(founded :Person) | founded { .name }][0] }][0] } AS person" )
61+ assertQuery(query, " MATCH (person:Person) RETURN person { .name,.age,livesIn:[(person)-[:LIVES_IN]->(personLivesIn :Location) | personLivesIn { .name,founded:[(personLivesIn )<-[:FOUNDED]-(personLivesInFounded :Person) | personLivesInFounded { .name }][0] }][0] } AS person" )
6162 }
6263
6364 @Test
6465 fun richRelationship () {
6566 val query = " { person { name born { date end { name } } } } "
66- assertQuery(query, " MATCH (person:Person) RETURN person { .name,born:[(person)-[born:BORN]->(bornEnd:Location) | born { .date,end:bornEnd { .name } }][0] } AS person" )
67+ assertQuery(query, " MATCH (person:Person) RETURN person { .name,born:[(person)-[personBorn:BORN]->(personBornEnd:Location) | personBorn { .date,end:personBornEnd { .name } }][0] } AS person" )
68+ }
69+
70+ @Test
71+ fun richRelationship2ndHop () {
72+ val query = " { person { name born { date end { name founded { name } } } } } "
73+ assertQuery(query, " MATCH (person:Person) RETURN person { .name,born:[(person)-[personBorn:BORN]->(personBornEnd:Location) | personBorn { .date,end:personBornEnd { .name,founded:[(personBornEnd)<-[:FOUNDED]-(personBornEndFounded:Person) | personBornEndFounded { .name }][0] } }][0] } AS person" )
74+ }
75+ @Test
76+ fun richRelationship3rdHop () {
77+ val query = " { person { name born { date end { name founded { name born { date end { name } } } } } } } "
78+ assertQuery(query, " MATCH (person:Person) RETURN person { .name,born:[(person)-[personBorn:BORN]->(personBornEnd:Location) | personBorn { .date,end:personBornEnd { .name,founded:[(personBornEnd)<-[:FOUNDED]-(personBornEndFounded:Person) | personBornEndFounded { .name,born:[(personBornEndFounded)-[personBornEndFoundedBorn:BORN]->(personBornEndFoundedBornEnd:Location) | personBornEndFoundedBorn { .date,end:personBornEndFoundedBornEnd { .name } }][0] }][0] } }][0] } AS person" )
6779 }
6880
6981 @Test
7082 fun nestedQueryParameter () {
7183 val query = """ { person { name age livesIn(name:"Berlin") { name } } } """
72- assertQuery(query, " MATCH (person:Person) RETURN person { .name,.age,livesIn:[(person)-[:LIVES_IN]->(livesIn :Location) WHERE livesIn .name = \$ livesInName | livesIn { .name }][0] } AS person" ,
73- mapOf (" livesInName " to " Berlin" ))
84+ assertQuery(query, " MATCH (person:Person) RETURN person { .name,.age,livesIn:[(person)-[:LIVES_IN]->(personLivesIn :Location) WHERE personLivesIn .name = \$ personLivesInName | personLivesIn { .name }][0] } AS person" ,
85+ mapOf (" personLivesInName " to " Berlin" ))
7486 }
7587
7688 @Test
7789 fun nestedQueryMulti () {
7890 val query = " { person { name age livedIn { name } } } "
79- assertQuery(query, " MATCH (person:Person) RETURN person { .name,.age,livedIn:[(person)-[:LIVED_IN]->(livedIn :Location) | livedIn { .name }] } AS person" )
91+ assertQuery(query, " MATCH (person:Person) RETURN person { .name,.age,livedIn:[(person)-[:LIVED_IN]->(personLivedIn :Location) | personLivedIn { .name }] } AS person" )
8092 }
8193
8294 @Test
8395 fun nestedQuerySliceOffset () {
8496 val query = " { person { livedIn(offset:3) { name } } } "
85- assertQuery(query, " MATCH (person:Person) RETURN person { livedIn:[(person)-[:LIVED_IN]->(livedIn :Location) | livedIn { .name }][3..] } AS person" )
97+ assertQuery(query, " MATCH (person:Person) RETURN person { livedIn:[(person)-[:LIVED_IN]->(personLivedIn :Location) | personLivedIn { .name }][3..] } AS person" )
8698 }
8799 @Test
88100 fun nestedQuerySliceFirstOffset () {
89101 val query = " { person { livedIn(first:2,offset:3) { name } } } "
90- assertQuery(query, " MATCH (person:Person) RETURN person { livedIn:[(person)-[:LIVED_IN]->(livedIn :Location) | livedIn { .name }][3..5] } AS person" )
102+ assertQuery(query, " MATCH (person:Person) RETURN person { livedIn:[(person)-[:LIVED_IN]->(personLivedIn :Location) | personLivedIn { .name }][3..5] } AS person" )
91103 }
92104
93105 @Test
94106 fun nestedQuerySliceFirst () {
95107 val query = " { person { livedIn(first:2) { name } } } "
96- assertQuery(query, " MATCH (person:Person) RETURN person { livedIn:[(person)-[:LIVED_IN]->(livedIn :Location) | livedIn { .name }][0..2] } AS person" )
108+ assertQuery(query, " MATCH (person:Person) RETURN person { livedIn:[(person)-[:LIVED_IN]->(personLivedIn :Location) | personLivedIn { .name }][0..2] } AS person" )
97109 }
98110
99111 @Test
0 commit comments