Skip to content

Commit 7e45a7a

Browse files
authored
Update spring boot dgs example (#254)
1 parent eee081e commit 7e45a7a

File tree

2 files changed

+31
-28
lines changed

2 files changed

+31
-28
lines changed

examples/dgs-spring-boot/pom.xml

Lines changed: 20 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@
1515
<description>Example for using neo4j-graphql-java with Spring Boot and Netflix Domain Graph Service (DGS)</description>
1616

1717
<properties>
18-
<testcontainers.version>1.16.0</testcontainers.version>
19-
<spring-boot.version>2.3.10.RELEASE</spring-boot.version>
18+
<testcontainers.version>1.16.2</testcontainers.version>
19+
<spring-boot.version>2.5.6</spring-boot.version>
2020
</properties>
2121

2222
<dependencies>
@@ -46,7 +46,12 @@
4646
<dependency>
4747
<groupId>com.netflix.graphql.dgs</groupId>
4848
<artifactId>graphql-dgs-spring-boot-starter</artifactId>
49-
<version>3.12.1</version>
49+
<version>4.8.3</version>
50+
</dependency>
51+
<dependency>
52+
<groupId>com.netflix.graphql.dgs.codegen</groupId>
53+
<artifactId>graphql-dgs-codegen-client-core</artifactId>
54+
<version>5.1.9</version>
5055
</dependency>
5156

5257
<!-- Kotlin dependencies -->
@@ -100,6 +105,17 @@
100105
<plugin>
101106
<groupId>org.springframework.boot</groupId>
102107
<artifactId>spring-boot-maven-plugin</artifactId>
108+
<version>${spring-boot.version}</version>
109+
</plugin>
110+
<plugin>
111+
<groupId>org.jetbrains.kotlin</groupId>
112+
<artifactId>kotlin-maven-plugin</artifactId>
113+
<configuration>
114+
<sourceDirs>
115+
<source>src/main/kotlin</source>
116+
<source>${project.build.directory}/generated-sources</source>
117+
</sourceDirs>
118+
</configuration>
103119
</plugin>
104120
<plugin>
105121
<groupId>org.neo4j</groupId>
@@ -131,7 +147,7 @@
131147
<plugin>
132148
<groupId>io.github.deweyjose</groupId>
133149
<artifactId>graphqlcodegen-maven-plugin</artifactId>
134-
<version>1.10</version>
150+
<version>1.14</version>
135151
<executions>
136152
<execution>
137153
<goals>
@@ -150,23 +166,6 @@
150166
</execution>
151167
</executions>
152168
</plugin>
153-
<plugin>
154-
<groupId>org.codehaus.mojo</groupId>
155-
<artifactId>build-helper-maven-plugin</artifactId>
156-
<executions>
157-
<execution>
158-
<phase>generate-sources</phase>
159-
<goals>
160-
<goal>add-source</goal>
161-
</goals>
162-
<configuration>
163-
<sources>
164-
<source>${project.build.directory}/generated-sources</source>
165-
</sources>
166-
</configuration>
167-
</execution>
168-
</executions>
169-
</plugin>
170169
</plugins>
171170
</build>
172171
</project>

examples/dgs-spring-boot/src/test/kotlin/org/neo4j/graphql/examples/dgsspringboot/datafetcher/AdditionalDataFetcherTest.kt

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@ import org.neo4j.graphql.examples.dgsspringboot.types.DgsConstants
1313
import org.neo4j.graphql.examples.dgsspringboot.types.client.MoviesGraphQLQuery
1414
import org.neo4j.graphql.examples.dgsspringboot.types.client.MoviesProjectionRoot
1515
import org.neo4j.graphql.examples.dgsspringboot.types.types.Movie
16+
import org.neo4j.graphql.examples.dgsspringboot.types.types.MovieOptions
17+
import org.neo4j.graphql.examples.dgsspringboot.types.types.MovieSort
18+
import org.neo4j.graphql.examples.dgsspringboot.types.types.SortDirection
1619
import org.skyscreamer.jsonassert.JSONAssert
1720
import org.springframework.beans.factory.annotation.Autowired
1821
import org.springframework.boot.autoconfigure.EnableAutoConfiguration
@@ -56,8 +59,9 @@ internal class AdditionalDataFetcherTest(
5659
fun testHybridDataFetcher() {
5760

5861
val graphQLQueryRequest = GraphQLQueryRequest(
59-
// there is an issue with empty fields of input type (https://github.com/Netflix/dgs-codegen/issues/140)
60-
MoviesGraphQLQuery(),
62+
MoviesGraphQLQuery.newRequest()
63+
.options(MovieOptions(sort = listOf(MovieSort(title = SortDirection.DESC))))
64+
.build(),
6165
MoviesProjectionRoot().also { movie ->
6266
movie.title()
6367
movie.bar()
@@ -68,7 +72,7 @@ internal class AdditionalDataFetcherTest(
6872
)
6973

7074
val request = graphQLQueryRequest.serialize()
71-
Assertions.assertThat(request).isEqualTo("query {movies{ title bar javaData { name } } }")
75+
Assertions.assertThat(request).isEqualTo("query {movies(options: {sort:[{title:DESC }] }){ title bar javaData { name } } }")
7276

7377
val response = dgsQueryExecutor.executeAndGetDocumentContext(request)
7478

@@ -78,11 +82,11 @@ internal class AdditionalDataFetcherTest(
7882
"data": {
7983
"movies": [
8084
{
81-
"title": "The Matrix",
85+
"title": "The Matrix Revolutions",
8286
"bar": "foo",
8387
"javaData": [
8488
{
85-
"name": "test The Matrix"
89+
"name": "test The Matrix Revolutions"
8690
}
8791
]
8892
},
@@ -96,11 +100,11 @@ internal class AdditionalDataFetcherTest(
96100
]
97101
},
98102
{
99-
"title": "The Matrix Revolutions",
103+
"title": "The Matrix",
100104
"bar": "foo",
101105
"javaData": [
102106
{
103-
"name": "test The Matrix Revolutions"
107+
"name": "test The Matrix"
104108
}
105109
]
106110
}

0 commit comments

Comments
 (0)