diff --git a/core/pom.xml b/core/pom.xml index c46d2d98..6430609c 100644 --- a/core/pom.xml +++ b/core/pom.xml @@ -14,16 +14,10 @@ Neo4j GraphQL Java GraphQL to Cypher Mapping - - 3.5.6 - 1.7.2 - - org.neo4j.driver neo4j-java-driver - ${driver.version} test @@ -70,7 +64,6 @@ org.junit.jupiter junit-jupiter - 5.5.1 test @@ -98,4 +91,13 @@ + + + + org.neo4j + neo4j-kernel + ${neo4j.version} + + + diff --git a/core/src/test/resources/issues/gh-112.adoc b/core/src/test/resources/issues/gh-112.adoc new file mode 100644 index 00000000..4f1ca611 --- /dev/null +++ b/core/src/test/resources/issues/gh-112.adoc @@ -0,0 +1,140 @@ +:toc: + += Github Issue #112: deleting bidirectional relationships + +== Schema + +[source,graphql,schema=true] +---- +type User +{ + name: String! + uuid: ID! + associates: [User!] @relation(name:"ASSOCIATES_WITH", direction:BOTH) +} +---- + +== Test Data + +[source,cypher,test-data=true] +---- +CREATE + (pete:User{ name: 'Pete', uuid: '1' }), + (fred:User{ name: 'Fred', uuid: '2' }), + (harry:User{ name: 'Harry', uuid: '3' }), + (pete)<-[:ASSOCIATES_WITH]-(fred), + (fred)<-[:ASSOCIATES_WITH]-(harry) +---- + +== Query + +.GraphQL-Query +[source,graphql] +---- +query { + user(uuid: $uuid) { + uuid + name + associates { name uuid } + } +} +---- + +.Query variables +[source,json,request=true] +---- +{ + "uuid": "2" +} +---- + +.GraphQL-Response +[source,json,response=true] +---- +{ + "user" : [ { + "associates" : [ { + "name" : "Harry", + "uuid" : "3" + }, { + "name" : "Pete", + "uuid" : "1" + } ], + "name" : "Fred", + "uuid" : "2" + } ] +} +---- + +.Cypher Params +[source,json] +---- +{ + "uuid" : "2" +} +---- + +.Cypher +[source,cypher] +---- +MATCH (user: User) +WHERE user.uuid = $uuid +RETURN user { + .uuid, + .name, + associates: [(user)-[: ASSOCIATES_WITH]-(userAssociates: User) | userAssociates { + .name, + .uuid + }] +} AS user +---- + +== Delete relation no matter of direction + +.GraphQL-Query +[source,graphql] +---- +mutation { + deleteUserAssociates(uuid: "2", associates: ["1", "3"]) { + name + associates { name uuid } + } +} +---- + +.GraphQL-Response +[source,json,response=true] +---- +{ + "deleteUserAssociates" : { + "associates" : [ ], + "name" : "Fred" + } +} +---- + +.Cypher Params +[source,json] +---- +{ + "fromUuid" : "2", + "toAssociates" : [ "1", "3" ] +} +---- + +.Cypher +[source,cypher] +---- +MATCH (from: User { uuid: $fromUuid }) +MATCH (to: User) WHERE to.uuid IN $toAssociates +MATCH (from)-[r: ASSOCIATES_WITH]-(to) +DELETE r +WITH DISTINCT from AS deleteUserAssociates +RETURN deleteUserAssociates { + .name, + associates: [(deleteUserAssociates)-[: ASSOCIATES_WITH]-(deleteUserAssociatesAssociates: User) | deleteUserAssociatesAssociates { + .name, + .uuid + }] +} AS deleteUserAssociates +---- diff --git a/pom.xml b/pom.xml index 1c0925a4..45945300 100755 --- a/pom.xml +++ b/pom.xml @@ -25,9 +25,9 @@ 1.8 1.4.10 ${java.version} - 3.5.6 + 3.5.23 3.5.0.15 - 1.7.2 + 1.7.5 @@ -73,6 +73,26 @@ + + + + org.neo4j.driver + neo4j-java-driver + ${driver.version} + + + org.junit.jupiter + junit-jupiter + 5.5.1 + + + org.slf4j + slf4j-api + 1.7.30 + + + + ${project.basedir}/src/main/kotlin ${project.basedir}/src/test/kotlin