18
18
19
19
import java .net .URI ;
20
20
21
+ import org .jspecify .annotations .Nullable ;
21
22
import reactor .core .publisher .Mono ;
22
23
23
24
import org .springframework .core .io .ClassPathResource ;
24
25
import org .springframework .core .io .Resource ;
25
26
import org .springframework .http .MediaType ;
27
+ import org .springframework .util .Assert ;
26
28
import org .springframework .util .StringUtils ;
27
29
import org .springframework .web .reactive .function .server .ServerRequest ;
28
30
import org .springframework .web .reactive .function .server .ServerResponse ;
@@ -39,7 +41,7 @@ public class GraphiQlHandler {
39
41
40
42
private final String graphQlPath ;
41
43
42
- private final String graphQlWsPath ;
44
+ private final @ Nullable String graphQlWsPath ;
43
45
44
46
private final Resource htmlResource ;
45
47
@@ -50,7 +52,7 @@ public class GraphiQlHandler {
50
52
* @param graphQlPath the path to the GraphQL endpoint
51
53
* @param graphQlWsPath optional path to the GraphQL WebSocket endpoint
52
54
*/
53
- public GraphiQlHandler (String graphQlPath , String graphQlWsPath ) {
55
+ public GraphiQlHandler (String graphQlPath , @ Nullable String graphQlWsPath ) {
54
56
this (graphQlPath , graphQlWsPath , new ClassPathResource ("graphiql/index.html" ));
55
57
}
56
58
@@ -60,7 +62,9 @@ public GraphiQlHandler(String graphQlPath, String graphQlWsPath) {
60
62
* @param graphQlWsPath optional path to the GraphQL WebSocket endpoint
61
63
* @param htmlResource the GraphiQL page to serve
62
64
*/
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" );
64
68
this .graphQlPath = graphQlPath ;
65
69
this .graphQlWsPath = graphQlWsPath ;
66
70
this .htmlResource = htmlResource ;
0 commit comments