@@ -87,9 +87,10 @@ private GraphQLInvocationInput getGraphQLInvocationInput(
87
87
}
88
88
});
89
89
90
- String query = read (inputStream );
90
+ String query = read (inputStream , request . getCharacterEncoding () );
91
91
if ("query" .equals (key ) && isSingleQuery (query )) {
92
- GraphQLRequest graphqlRequest = buildRequestFromQuery (query , graphQLObjectMapper , parts );
92
+ GraphQLRequest graphqlRequest =
93
+ buildRequestFromQuery (query , graphQLObjectMapper , parts , request .getCharacterEncoding ());
93
94
variablesMap .ifPresent (m -> mapMultipartVariables (graphqlRequest , m , parts ));
94
95
return invocationInputFactory .create (graphqlRequest , request , response );
95
96
} else if (isSingleQuery (query )) {
@@ -109,6 +110,7 @@ private Optional<Part> findPart(Map<String, List<Part>> parts) {
109
110
.filter (parts ::containsKey )
110
111
.map (key -> getPart (parts , key ))
111
112
.findFirst ()
113
+ .filter (Optional ::isPresent )
112
114
.map (Optional ::get );
113
115
}
114
116
@@ -141,33 +143,38 @@ private void mapMultipartVariables(
141
143
}
142
144
143
145
private GraphQLRequest buildRequestFromQuery (
144
- String query , GraphQLObjectMapper graphQLObjectMapper , Map <String , List <Part >> parts )
146
+ String query ,
147
+ GraphQLObjectMapper graphQLObjectMapper ,
148
+ Map <String , List <Part >> parts ,
149
+ String charset )
145
150
throws IOException {
146
151
Map <String , Object > variables = null ;
147
152
final Optional <Part > variablesItem = getPart (parts , "variables" );
148
153
if (variablesItem .isPresent ()) {
149
154
variables =
150
- graphQLObjectMapper .deserializeVariables (read (variablesItem .get ().getInputStream ()));
155
+ graphQLObjectMapper .deserializeVariables (
156
+ read (variablesItem .get ().getInputStream (), charset ));
151
157
}
152
158
153
159
Map <String , Object > extensions = null ;
154
160
final Optional <Part > extensionsItem = getPart (parts , "extensions" );
155
161
if (extensionsItem .isPresent ()) {
156
162
extensions =
157
- graphQLObjectMapper .deserializeExtensions (read (extensionsItem .get ().getInputStream ()));
163
+ graphQLObjectMapper .deserializeExtensions (
164
+ read (extensionsItem .get ().getInputStream (), charset ));
158
165
}
159
166
160
167
String operationName = null ;
161
168
final Optional <Part > operationNameItem = getPart (parts , "operationName" );
162
169
if (operationNameItem .isPresent ()) {
163
- operationName = read (operationNameItem .get ().getInputStream ()).trim ();
170
+ operationName = read (operationNameItem .get ().getInputStream (), charset ).trim ();
164
171
}
165
172
166
173
return new GraphQLRequest (query , variables , extensions , operationName );
167
174
}
168
175
169
- private String read (InputStream inputStream ) throws IOException {
170
- try (InputStreamReader streamReader = new InputStreamReader (inputStream );
176
+ private String read (InputStream inputStream , String charset ) throws IOException {
177
+ try (InputStreamReader streamReader = new InputStreamReader (inputStream , charset );
171
178
BufferedReader reader = new BufferedReader (streamReader )) {
172
179
return reader .lines ().collect (joining ());
173
180
}
0 commit comments