@@ -39,6 +39,7 @@ public Object graphqlPOST(
39
39
@ Nullable @ RequestParam (value = "query" , required = false ) String query ,
40
40
@ Nullable @ RequestParam (value = "operationName" , required = false ) String operationName ,
41
41
@ Nullable @ RequestParam (value = "variables" , required = false ) String variablesJson ,
42
+ @ Nullable @ RequestParam (value = "extensions" , required = false ) String extensionsJson ,
42
43
@ Nullable @ RequestBody (required = false ) String body ,
43
44
ServerWebExchange serverWebExchange ) {
44
45
@@ -58,6 +59,7 @@ public Object graphqlPOST(
58
59
request .getQuery (),
59
60
request .getOperationName (),
60
61
request .getVariables (),
62
+ request .getExtensions (),
61
63
serverWebExchange );
62
64
}
63
65
@@ -68,15 +70,20 @@ public Object graphqlPOST(
68
70
69
71
if (query != null ) {
70
72
return executeRequest (
71
- query , operationName , convertVariablesJson (variablesJson ), serverWebExchange );
73
+ query ,
74
+ operationName ,
75
+ convertVariablesJson (variablesJson ),
76
+ convertExtensionsJson (extensionsJson ),
77
+ serverWebExchange );
72
78
}
73
79
74
80
// * If the "application/graphql" Content-Type header is present,
75
81
// treat the HTTP POST body contents as the GraphQL query string.
76
82
77
83
if ("application/graphql" .equals (contentType .toString ())
78
84
|| "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 );
80
87
}
81
88
82
89
throw new ResponseStatusException (
@@ -88,10 +95,14 @@ public Object graphqlGET(
88
95
@ Nullable @ RequestParam ("query" ) String query ,
89
96
@ Nullable @ RequestParam (value = "operationName" , required = false ) String operationName ,
90
97
@ Nullable @ RequestParam (value = "variables" , required = false ) String variablesJson ,
98
+ @ Nullable @ RequestParam (value = "extensions" , required = false ) String extensionsJson ,
91
99
ServerWebExchange serverWebExchange ) {
92
-
93
100
return executeRequest (
94
- query , operationName , convertVariablesJson (variablesJson ), serverWebExchange );
101
+ query == null ? "" : query ,
102
+ operationName ,
103
+ convertVariablesJson (variablesJson ),
104
+ convertExtensionsJson (extensionsJson ),
105
+ serverWebExchange );
95
106
}
96
107
97
108
private Map <String , Object > convertVariablesJson (String jsonMap ) {
@@ -100,10 +111,17 @@ private Map<String, Object> convertVariablesJson(String jsonMap) {
100
111
.orElseGet (Collections ::emptyMap );
101
112
}
102
113
114
+ private Map <String , Object > convertExtensionsJson (String jsonMap ) {
115
+ return Optional .ofNullable (jsonMap )
116
+ .map (objectMapper ::deserializeExtensions )
117
+ .orElseGet (Collections ::emptyMap );
118
+ }
119
+
103
120
protected abstract Object executeRequest (
104
121
String query ,
105
122
String operationName ,
106
123
Map <String , Object > variables ,
124
+ Map <String , Object > extensions ,
107
125
ServerWebExchange serverWebExchange );
108
126
109
127
protected Object handleBodyParsingException (Exception exception ) {
0 commit comments