@@ -39,6 +39,7 @@ public Object graphqlPOST(
3939 @ Nullable @ RequestParam (value = "query" , required = false ) String query ,
4040 @ Nullable @ RequestParam (value = "operationName" , required = false ) String operationName ,
4141 @ Nullable @ RequestParam (value = "variables" , required = false ) String variablesJson ,
42+ @ Nullable @ RequestParam (value = "extensions" , required = false ) String extensionsJson ,
4243 @ Nullable @ RequestBody (required = false ) String body ,
4344 ServerWebExchange serverWebExchange ) {
4445
@@ -58,6 +59,7 @@ public Object graphqlPOST(
5859 request .getQuery (),
5960 request .getOperationName (),
6061 request .getVariables (),
62+ request .getExtensions (),
6163 serverWebExchange );
6264 }
6365
@@ -68,15 +70,20 @@ public Object graphqlPOST(
6870
6971 if (query != null ) {
7072 return executeRequest (
71- query , operationName , convertVariablesJson (variablesJson ), serverWebExchange );
73+ query ,
74+ operationName ,
75+ convertVariablesJson (variablesJson ),
76+ convertExtensionsJson (extensionsJson ),
77+ serverWebExchange );
7278 }
7379
7480 // * If the "application/graphql" Content-Type header is present,
7581 // treat the HTTP POST body contents as the GraphQL query string.
7682
7783 if ("application/graphql" .equals (contentType .toString ())
7884 || "application/graphql; charset=utf-8" .equals (contentType .toString ())) {
79- return executeRequest (body , null , Collections .emptyMap (), serverWebExchange );
85+ return executeRequest (
86+ body , null , Collections .emptyMap (), Collections .emptyMap (), serverWebExchange );
8087 }
8188
8289 throw new ResponseStatusException (
@@ -88,10 +95,14 @@ public Object graphqlGET(
8895 @ Nullable @ RequestParam ("query" ) String query ,
8996 @ Nullable @ RequestParam (value = "operationName" , required = false ) String operationName ,
9097 @ Nullable @ RequestParam (value = "variables" , required = false ) String variablesJson ,
98+ @ Nullable @ RequestParam (value = "extensions" , required = false ) String extensionsJson ,
9199 ServerWebExchange serverWebExchange ) {
92-
93100 return executeRequest (
94- query , operationName , convertVariablesJson (variablesJson ), serverWebExchange );
101+ query == null ? "" : query ,
102+ operationName ,
103+ convertVariablesJson (variablesJson ),
104+ convertExtensionsJson (extensionsJson ),
105+ serverWebExchange );
95106 }
96107
97108 private Map <String , Object > convertVariablesJson (String jsonMap ) {
@@ -100,10 +111,17 @@ private Map<String, Object> convertVariablesJson(String jsonMap) {
100111 .orElseGet (Collections ::emptyMap );
101112 }
102113
114+ private Map <String , Object > convertExtensionsJson (String jsonMap ) {
115+ return Optional .ofNullable (jsonMap )
116+ .map (objectMapper ::deserializeExtensions )
117+ .orElseGet (Collections ::emptyMap );
118+ }
119+
103120 protected abstract Object executeRequest (
104121 String query ,
105122 String operationName ,
106123 Map <String , Object > variables ,
124+ Map <String , Object > extensions ,
107125 ServerWebExchange serverWebExchange );
108126
109127 protected Object handleBodyParsingException (Exception exception ) {
0 commit comments