Skip to content

Commit abec1b6

Browse files
committed
Add missing Nullable info in GraphiQL handlers
Fixes gh-1276
1 parent d8098ba commit abec1b6

File tree

2 files changed

+13
-6
lines changed

2 files changed

+13
-6
lines changed

spring-graphql/src/main/java/org/springframework/graphql/server/webflux/GraphiQlHandler.java

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,13 @@
1818

1919
import java.net.URI;
2020

21+
import org.jspecify.annotations.Nullable;
2122
import reactor.core.publisher.Mono;
2223

2324
import org.springframework.core.io.ClassPathResource;
2425
import org.springframework.core.io.Resource;
2526
import org.springframework.http.MediaType;
27+
import org.springframework.util.Assert;
2628
import org.springframework.util.StringUtils;
2729
import org.springframework.web.reactive.function.server.ServerRequest;
2830
import org.springframework.web.reactive.function.server.ServerResponse;
@@ -39,7 +41,7 @@ public class GraphiQlHandler {
3941

4042
private final String graphQlPath;
4143

42-
private final String graphQlWsPath;
44+
private final @Nullable String graphQlWsPath;
4345

4446
private final Resource htmlResource;
4547

@@ -50,7 +52,7 @@ public class GraphiQlHandler {
5052
* @param graphQlPath the path to the GraphQL endpoint
5153
* @param graphQlWsPath optional path to the GraphQL WebSocket endpoint
5254
*/
53-
public GraphiQlHandler(String graphQlPath, String graphQlWsPath) {
55+
public GraphiQlHandler(String graphQlPath, @Nullable String graphQlWsPath) {
5456
this(graphQlPath, graphQlWsPath, new ClassPathResource("graphiql/index.html"));
5557
}
5658

@@ -60,7 +62,9 @@ public GraphiQlHandler(String graphQlPath, String graphQlWsPath) {
6062
* @param graphQlWsPath optional path to the GraphQL WebSocket endpoint
6163
* @param htmlResource the GraphiQL page to serve
6264
*/
63-
public GraphiQlHandler(String graphQlPath, String graphQlWsPath, Resource htmlResource) {
65+
public GraphiQlHandler(String graphQlPath, @Nullable String graphQlWsPath, Resource htmlResource) {
66+
Assert.hasText(graphQlPath, "graphQlPath should not be empty");
67+
Assert.notNull(htmlResource, "HtmlResource is required");
6468
this.graphQlPath = graphQlPath;
6569
this.graphQlWsPath = graphQlWsPath;
6670
this.htmlResource = htmlResource;

spring-graphql/src/main/java/org/springframework/graphql/server/webmvc/GraphiQlHandler.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818

1919
import java.net.URI;
2020

21+
import org.jspecify.annotations.Nullable;
22+
2123
import org.springframework.core.io.ClassPathResource;
2224
import org.springframework.core.io.Resource;
2325
import org.springframework.http.MediaType;
@@ -38,7 +40,7 @@ public class GraphiQlHandler {
3840

3941
private final String graphQlPath;
4042

41-
private final String graphQlWsPath;
43+
private final @Nullable String graphQlWsPath;
4244

4345
private final Resource htmlResource;
4446

@@ -49,7 +51,7 @@ public class GraphiQlHandler {
4951
* @param graphQlPath the path to the GraphQL HTTP endpoint
5052
* @param graphQlWsPath optional path to the GraphQL WebSocket endpoint
5153
*/
52-
public GraphiQlHandler(String graphQlPath, String graphQlWsPath) {
54+
public GraphiQlHandler(String graphQlPath, @Nullable String graphQlWsPath) {
5355
this(graphQlPath, graphQlWsPath, new ClassPathResource("graphiql/index.html"));
5456
}
5557

@@ -59,8 +61,9 @@ public GraphiQlHandler(String graphQlPath, String graphQlWsPath) {
5961
* @param graphQlWsPath optional path to the GraphQL WebSocket endpoint
6062
* @param htmlResource the GraphiQL page to serve
6163
*/
62-
public GraphiQlHandler(String graphQlPath, String graphQlWsPath, Resource htmlResource) {
64+
public GraphiQlHandler(String graphQlPath, @Nullable String graphQlWsPath, Resource htmlResource) {
6365
Assert.hasText(graphQlPath, "graphQlPath should not be empty");
66+
Assert.notNull(htmlResource, "HtmlResource is required");
6467
this.graphQlPath = graphQlPath;
6568
this.graphQlWsPath = graphQlWsPath;
6669
this.htmlResource = htmlResource;

0 commit comments

Comments
 (0)