@@ -87,9 +87,10 @@ private GraphQLInvocationInput getGraphQLInvocationInput(
8787 }
8888 });
8989
90- String query = read (inputStream );
90+ String query = read (inputStream , request . getCharacterEncoding () );
9191 if ("query" .equals (key ) && isSingleQuery (query )) {
92- GraphQLRequest graphqlRequest = buildRequestFromQuery (query , graphQLObjectMapper , parts );
92+ GraphQLRequest graphqlRequest =
93+ buildRequestFromQuery (query , graphQLObjectMapper , parts , request .getCharacterEncoding ());
9394 variablesMap .ifPresent (m -> mapMultipartVariables (graphqlRequest , m , parts ));
9495 return invocationInputFactory .create (graphqlRequest , request , response );
9596 } else if (isSingleQuery (query )) {
@@ -109,6 +110,7 @@ private Optional<Part> findPart(Map<String, List<Part>> parts) {
109110 .filter (parts ::containsKey )
110111 .map (key -> getPart (parts , key ))
111112 .findFirst ()
113+ .filter (Optional ::isPresent )
112114 .map (Optional ::get );
113115 }
114116
@@ -141,33 +143,38 @@ private void mapMultipartVariables(
141143 }
142144
143145 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 )
145150 throws IOException {
146151 Map <String , Object > variables = null ;
147152 final Optional <Part > variablesItem = getPart (parts , "variables" );
148153 if (variablesItem .isPresent ()) {
149154 variables =
150- graphQLObjectMapper .deserializeVariables (read (variablesItem .get ().getInputStream ()));
155+ graphQLObjectMapper .deserializeVariables (
156+ read (variablesItem .get ().getInputStream (), charset ));
151157 }
152158
153159 Map <String , Object > extensions = null ;
154160 final Optional <Part > extensionsItem = getPart (parts , "extensions" );
155161 if (extensionsItem .isPresent ()) {
156162 extensions =
157- graphQLObjectMapper .deserializeExtensions (read (extensionsItem .get ().getInputStream ()));
163+ graphQLObjectMapper .deserializeExtensions (
164+ read (extensionsItem .get ().getInputStream (), charset ));
158165 }
159166
160167 String operationName = null ;
161168 final Optional <Part > operationNameItem = getPart (parts , "operationName" );
162169 if (operationNameItem .isPresent ()) {
163- operationName = read (operationNameItem .get ().getInputStream ()).trim ();
170+ operationName = read (operationNameItem .get ().getInputStream (), charset ).trim ();
164171 }
165172
166173 return new GraphQLRequest (query , variables , extensions , operationName );
167174 }
168175
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 );
171178 BufferedReader reader = new BufferedReader (streamReader )) {
172179 return reader .lines ().collect (joining ());
173180 }
0 commit comments