1818
1919import java .net .URI ;
2020
21+ import org .jspecify .annotations .Nullable ;
2122import reactor .core .publisher .Mono ;
2223
2324import org .springframework .core .io .ClassPathResource ;
2425import org .springframework .core .io .Resource ;
2526import org .springframework .http .MediaType ;
27+ import org .springframework .util .Assert ;
2628import org .springframework .util .StringUtils ;
2729import org .springframework .web .reactive .function .server .ServerRequest ;
2830import 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 ;
0 commit comments