This repository was archived by the owner on Dec 19, 2023. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +3
-7
lines changed
graphql-kickstart-spring-support/src/main/java/graphql/kickstart/spring Expand file tree Collapse file tree 1 file changed +3
-7
lines changed Original file line number Diff line number Diff line change 1818import java .io .IOException ;
1919import java .util .Collections ;
2020import java .util .Map ;
21+ import java .util .Optional ;
2122
2223@ RequiredArgsConstructor
2324public abstract class AbstractGraphQLController {
@@ -34,9 +35,7 @@ public Object graphqlPOST(
3435 @ Nullable @ RequestBody (required = false ) String body ,
3536 ServerWebExchange serverWebExchange ) throws IOException {
3637
37- if (body == null ) {
38- body = "" ;
39- }
38+ body = Optional .ofNullable (body ).orElse ("" );
4039
4140 // https://graphql.org/learn/serving-over-http/#post-request
4241 //
@@ -107,10 +106,7 @@ public Object graphqlGET(
107106 }
108107
109108 private Map <String , Object > convertVariablesJson (String jsonMap ) {
110- if (jsonMap == null ) {
111- return Collections .emptyMap ();
112- }
113- return objectMapper .deserializeVariables (jsonMap );
109+ return Optional .ofNullable (jsonMap ).map (objectMapper ::deserializeVariables ).orElseGet (Collections ::emptyMap );
114110 }
115111
116112 protected abstract Object executeRequest (
You can’t perform that action at this time.
0 commit comments