@@ -778,6 +778,39 @@ test('Add relationship mutation', t => {
778
778
) ;
779
779
} ) ;
780
780
781
+ test ( 'Add relationship mutation and query only outgoing nodes' , t => {
782
+ const graphQLQuery = `mutation someMutation {
783
+ AddMovieGenres(
784
+ from: { movieId: "123" },
785
+ to: { name: "Action" }
786
+ ) {
787
+ to {
788
+ name
789
+ }
790
+ }
791
+ }` ,
792
+ expectedCypherQuery = `
793
+ MATCH (\`movie_from\`:\`Movie\`${ ADDITIONAL_MOVIE_LABELS } {movieId: $from.movieId})
794
+ MATCH (\`genre_to\`:\`Genre\` {name: $to.name})
795
+ CREATE (\`movie_from\`)-[\`in_genre_relation\`:\`IN_GENRE\`]->(\`genre_to\`)
796
+ RETURN \`in_genre_relation\` { to: \`genre_to\` { .name } } AS \`_AddMovieGenresPayload\`;
797
+ ` ;
798
+
799
+ t . plan ( 1 ) ;
800
+ return augmentedSchemaCypherTestRunner (
801
+ t ,
802
+ graphQLQuery ,
803
+ {
804
+ from : { movieId : '123' } ,
805
+ to : { name : 'Action' } ,
806
+ first : - 1 ,
807
+ offset : 0
808
+ } ,
809
+ expectedCypherQuery ,
810
+ { }
811
+ ) ;
812
+ } ) ;
813
+
781
814
test ( 'Merge relationship mutation' , t => {
782
815
const graphQLQuery = `mutation someMutation {
783
816
MergeMovieGenres(
@@ -1053,6 +1086,63 @@ test('Update relationship mutation with relationship property', t => {
1053
1086
) ;
1054
1087
} ) ;
1055
1088
1089
+ test ( 'Update relationship mutation with relationship property and query only outgoing nodes' , t => {
1090
+ const graphQLQuery = `mutation someMutation {
1091
+ UpdateUserRated(
1092
+ from: { userId: "123" }
1093
+ to: { movieId: "2kljghd" }
1094
+ data: {
1095
+ rating: 1
1096
+ location: { longitude: 3.0, latitude: 4.5, height: 12.5 }
1097
+ }
1098
+ ) {
1099
+ to {
1100
+ _id
1101
+ movieId
1102
+ title
1103
+ ratings {
1104
+ rating
1105
+ User {
1106
+ _id
1107
+ userId
1108
+ name
1109
+ }
1110
+ }
1111
+ }
1112
+ rating
1113
+ }
1114
+ }
1115
+ ` ,
1116
+ expectedCypherQuery = `
1117
+ MATCH (\`user_from\`:\`User\` {userId: $from.userId})
1118
+ MATCH (\`movie_to\`:\`Movie\`${ ADDITIONAL_MOVIE_LABELS } {movieId: $to.movieId})
1119
+ MATCH (\`user_from\`)-[\`rated_relation\`:\`RATED\`]->(\`movie_to\`)
1120
+ SET \`rated_relation\` += {rating:$data.rating,location: point($data.location)}
1121
+ RETURN \`rated_relation\` { to: \`movie_to\` {_id: ID(\`movie_to\`), .movieId , .title ,ratings: [(\`movie_to\`)<-[\`movie_to_ratings_relation\`:\`RATED\`]-(:\`User\`) | movie_to_ratings_relation { .rating ,User: head([(:\`Movie\`${ ADDITIONAL_MOVIE_LABELS } )<-[\`movie_to_ratings_relation\`]-(\`movie_to_ratings_User\`:\`User\`) | movie_to_ratings_User {_id: ID(\`movie_to_ratings_User\`), .userId , .name }]) }] } , .rating } AS \`_UpdateUserRatedPayload\`;
1122
+ ` ;
1123
+
1124
+ t . plan ( 1 ) ;
1125
+ return augmentedSchemaCypherTestRunner (
1126
+ t ,
1127
+ graphQLQuery ,
1128
+ {
1129
+ from : { userId : '123' } ,
1130
+ to : { movieId : '2kljghd' } ,
1131
+ data : {
1132
+ rating : 1 ,
1133
+ location : {
1134
+ longitude : 3.0 ,
1135
+ latitude : 4.5 ,
1136
+ height : 12.5
1137
+ }
1138
+ } ,
1139
+ first : - 1 ,
1140
+ offset : 0
1141
+ } ,
1142
+ expectedCypherQuery
1143
+ ) ;
1144
+ } ) ;
1145
+
1056
1146
test ( 'Add reflexive relationship mutation with relationship property' , t => {
1057
1147
const graphQLQuery = `mutation {
1058
1148
AddUserFriends(
@@ -1755,6 +1845,41 @@ test('Remove relationship mutation', t => {
1755
1845
) ;
1756
1846
} ) ;
1757
1847
1848
+ test ( 'Remove relationship mutation and query only outgoing nodes' , t => {
1849
+ const graphQLQuery = `mutation someMutation {
1850
+ RemoveMovieGenres(
1851
+ from: { movieId: "123" },
1852
+ to: { name: "Action" }
1853
+ ) {
1854
+ to {
1855
+ _id
1856
+ name
1857
+ }
1858
+ }
1859
+ }` ,
1860
+ expectedCypherQuery = `
1861
+ MATCH (\`movie_from\`:\`Movie\`${ ADDITIONAL_MOVIE_LABELS } {movieId: $from.movieId})
1862
+ MATCH (\`genre_to\`:\`Genre\` {name: $to.name})
1863
+ OPTIONAL MATCH (\`movie_from\`)-[\`movie_fromgenre_to\`:\`IN_GENRE\`]->(\`genre_to\`)
1864
+ DELETE \`movie_fromgenre_to\`
1865
+ WITH COUNT(*) AS scope, \`movie_from\` AS \`_movie_from\`, \`genre_to\` AS \`_genre_to\`
1866
+ RETURN {to: \`_genre_to\` {_id: ID(\`_genre_to\`), .name } } AS \`_RemoveMovieGenresPayload\`;
1867
+ ` ;
1868
+
1869
+ t . plan ( 1 ) ;
1870
+ return augmentedSchemaCypherTestRunner (
1871
+ t ,
1872
+ graphQLQuery ,
1873
+ {
1874
+ from : { movieId : '123' } ,
1875
+ to : { name : 'Action' } ,
1876
+ first : - 1 ,
1877
+ offset : 0
1878
+ } ,
1879
+ expectedCypherQuery
1880
+ ) ;
1881
+ } ) ;
1882
+
1758
1883
test ( 'Remove reflexive relationship mutation' , t => {
1759
1884
const graphQLQuery = `mutation {
1760
1885
RemoveUserFriends(
0 commit comments