Skip to content

Commit f4c5003

Browse files
meistermeierrstoyanchev
authored andcommitted
Add tests for Neo4j
Also mention Neo4j as compatible with the reactive stack and the QuerydslPredicateExecutor. See gh-734
1 parent e9f6894 commit f4c5003

File tree

8 files changed

+703
-2
lines changed

8 files changed

+703
-2
lines changed

spring-graphql-docs/src/docs/asciidoc/includes/data.adoc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,14 +50,14 @@ You can now register the above `DataFetcher` through a
5050
<<execution.graphqlsource.runtimewiring-configurer>>.
5151

5252
The `DataFetcher` builds a Querydsl `Predicate` from GraphQL arguments, and uses it to
53-
fetch data. Spring Data supports `QuerydslPredicateExecutor` for JPA, MongoDB, and LDAP.
53+
fetch data. Spring Data supports `QuerydslPredicateExecutor` for JPA, MongoDB, Neo4j, and LDAP.
5454

5555
NOTE: For a single argument that is a GraphQL input type, `QuerydslDataFetcher` nests one
5656
level down, and uses the values from the argument sub-map.
5757

5858
If the repository is `ReactiveQuerydslPredicateExecutor`, the builder returns
5959
`DataFetcher<Mono<Account>>` or `DataFetcher<Flux<Account>>`. Spring Data supports this
60-
variant for MongoDB.
60+
variant for MongoDB and Neo4j.
6161

6262

6363
[[data.querydsl.build]]

spring-graphql/build.gradle

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,11 @@ dependencies {
5151
testImplementation 'org.hibernate:hibernate-core'
5252
testImplementation 'org.hibernate.validator:hibernate-validator'
5353
testImplementation 'org.springframework.data:spring-data-mongodb'
54+
testImplementation 'org.springframework.data:spring-data-neo4j:7.1.1'
5455
testImplementation 'org.mongodb:mongodb-driver-sync'
5556
testImplementation 'org.mongodb:mongodb-driver-reactivestreams'
5657
testImplementation 'org.testcontainers:mongodb'
58+
testImplementation 'org.testcontainers:neo4j'
5759
testImplementation 'org.testcontainers:junit-jupiter'
5860
testImplementation 'org.springframework.security:spring-security-core'
5961
testImplementation 'com.querydsl:querydsl-core'
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
package org.springframework.graphql.data.query.neo4j;
2+
3+
import org.springframework.data.neo4j.core.schema.Id;
4+
import org.springframework.data.neo4j.core.schema.Node;
5+
6+
/**
7+
* @author Gerrit Meier
8+
*/
9+
@Node
10+
public class Author {
11+
12+
@Id
13+
String id;
14+
15+
String firstName;
16+
17+
String lastName;
18+
19+
// needed for response mapping
20+
public Author() {
21+
22+
}
23+
24+
public Author(String id, String firstName, String lastName) {
25+
this.id = id;
26+
this.firstName = firstName;
27+
this.lastName = lastName;
28+
}
29+
30+
public String getId() {
31+
return this.id;
32+
}
33+
34+
public void setId(String id) {
35+
this.id = id;
36+
}
37+
38+
public String getFirstName() {
39+
return this.firstName;
40+
}
41+
42+
public void setFirstName(String firstName) {
43+
this.firstName = firstName;
44+
}
45+
46+
public String getLastName() {
47+
return this.lastName;
48+
}
49+
50+
public void setLastName(String lastName) {
51+
this.lastName = lastName;
52+
}
53+
54+
public String getFullName() {
55+
return this.firstName + " " + this.lastName;
56+
}
57+
}
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
/*
2+
* Copyright 2020-2021 the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package org.springframework.graphql.data.query.neo4j;
18+
19+
import org.springframework.data.neo4j.core.schema.Id;
20+
import org.springframework.data.neo4j.core.schema.Node;
21+
import org.springframework.data.neo4j.core.schema.Relationship;
22+
23+
@Node
24+
public class Book {
25+
26+
@Id
27+
String id;
28+
29+
String name;
30+
31+
@Relationship("AUTHOR")
32+
Author author;
33+
34+
// needed for response mapping
35+
public Book() {
36+
37+
}
38+
39+
public Book(String id, String name, Author author) {
40+
this.id = id;
41+
this.name = name;
42+
this.author = author;
43+
}
44+
45+
public String getId() {
46+
return this.id;
47+
}
48+
49+
public void setId(String id) {
50+
this.id = id;
51+
}
52+
53+
public String getName() {
54+
return this.name;
55+
}
56+
57+
public void setName(String name) {
58+
this.name = name;
59+
}
60+
61+
public Author getAuthor() {
62+
return this.author;
63+
}
64+
65+
public void setAuthor(Author author) {
66+
this.author = author;
67+
}
68+
69+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
package org.springframework.graphql.data.query.neo4j;
2+
3+
import org.springframework.data.neo4j.repository.Neo4jRepository;
4+
import org.springframework.graphql.data.GraphQlRepository;
5+
6+
/**
7+
* @author Gerrit Meier
8+
*/
9+
@GraphQlRepository
10+
public interface BookNeo4jRepository extends Neo4jRepository<Book, String> {
11+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
package org.springframework.graphql.data.query.neo4j;
2+
3+
import org.springframework.data.neo4j.repository.ReactiveNeo4jRepository;
4+
import org.springframework.graphql.data.GraphQlRepository;
5+
6+
/**
7+
* @author Gerrit Meier
8+
*/
9+
@GraphQlRepository
10+
public interface BookReactiveNeo4jRepository extends ReactiveNeo4jRepository<Book, String> {
11+
}

0 commit comments

Comments
 (0)