5
5
import graphql .ExecutionResult ;
6
6
import graphql .introspection .IntrospectionQuery ;
7
7
import graphql .schema .GraphQLFieldDefinition ;
8
+ import graphql .servlet .config .GraphQLConfiguration ;
9
+ import graphql .servlet .context .ContextSetting ;
8
10
import graphql .servlet .core .GraphQLMBean ;
9
11
import graphql .servlet .core .GraphQLObjectMapper ;
10
12
import graphql .servlet .core .GraphQLQueryInvoker ;
11
13
import graphql .servlet .core .GraphQLServletListener ;
12
- import graphql .servlet .config . GraphQLConfiguration ;
13
- import graphql .servlet .context . ContextSetting ;
14
+ import graphql .servlet .core . internal . GraphQLRequest ;
15
+ import graphql .servlet .core . internal . VariableMapper ;
14
16
import graphql .servlet .input .BatchInputPreProcessResult ;
15
17
import graphql .servlet .input .BatchInputPreProcessor ;
16
18
import graphql .servlet .input .GraphQLBatchedInvocationInput ;
17
- import graphql .servlet .input .GraphQLSingleInvocationInput ;
18
19
import graphql .servlet .input .GraphQLInvocationInputFactory ;
19
- import graphql .servlet .core .internal .GraphQLRequest ;
20
- import graphql .servlet .core .internal .VariableMapper ;
20
+ import graphql .servlet .input .GraphQLSingleInvocationInput ;
21
21
import org .reactivestreams .Publisher ;
22
22
import org .reactivestreams .Subscriber ;
23
23
import org .reactivestreams .Subscription ;
@@ -136,15 +136,15 @@ public void init() {
136
136
}
137
137
if (path .contentEquals ("/schema.json" )) {
138
138
query (queryInvoker , graphQLObjectMapper , invocationInputFactory .create (INTROSPECTION_REQUEST , request , response ),
139
- request , response );
139
+ request , response );
140
140
} else {
141
141
String query = request .getParameter ("query" );
142
142
if (query != null ) {
143
143
144
144
if (isBatchedQuery (query )) {
145
145
List <GraphQLRequest > requests = graphQLObjectMapper .readBatchedGraphQLRequest (query );
146
146
GraphQLBatchedInvocationInput batchedInvocationInput =
147
- invocationInputFactory .createReadOnly (configuration .getContextSetting (), requests , request , response );
147
+ invocationInputFactory .createReadOnly (configuration .getContextSetting (), requests , request , response );
148
148
queryBatched (queryInvoker , batchedInvocationInput , request , response , configuration );
149
149
} else {
150
150
final Map <String , Object > variables = new HashMap <>();
@@ -155,8 +155,8 @@ public void init() {
155
155
String operationName = request .getParameter ("operationName" );
156
156
157
157
query (queryInvoker , graphQLObjectMapper ,
158
- invocationInputFactory .createReadOnly (new GraphQLRequest (query , variables , operationName ), request , response ),
159
- request , response );
158
+ invocationInputFactory .createReadOnly (new GraphQLRequest (query , variables , operationName ), request , response ),
159
+ request , response );
160
160
}
161
161
} else {
162
162
response .setStatus (STATUS_BAD_REQUEST );
@@ -174,8 +174,8 @@ public void init() {
174
174
if (APPLICATION_GRAPHQL .equals (request .getContentType ())) {
175
175
String query = CharStreams .toString (request .getReader ());
176
176
query (queryInvoker , graphQLObjectMapper ,
177
- invocationInputFactory .create (new GraphQLRequest (query , null , null ), request , response ),
178
- request , response );
177
+ invocationInputFactory .create (new GraphQLRequest (query , null , null ), request , response ),
178
+ request , response );
179
179
} else if (request .getContentType () != null && request .getContentType ().startsWith ("multipart/form-data" ) && !request .getParts ().isEmpty ()) {
180
180
final Map <String , List <Part >> fileItems = request .getParts ()
181
181
.stream ()
@@ -203,7 +203,7 @@ public void init() {
203
203
graphQLObjectMapper .readBatchedGraphQLRequest (inputStream );
204
204
variablesMap .ifPresent (map -> graphQLRequests .forEach (r -> mapMultipartVariables (r , map , fileItems )));
205
205
GraphQLBatchedInvocationInput batchedInvocationInput = invocationInputFactory .create (configuration .getContextSetting (),
206
- graphQLRequests , request , response );
206
+ graphQLRequests , request , response );
207
207
queryBatched (queryInvoker , batchedInvocationInput , request , response , configuration );
208
208
return ;
209
209
} else {
@@ -231,7 +231,7 @@ public void init() {
231
231
if (isBatchedQuery (inputStream )) {
232
232
List <GraphQLRequest > requests = graphQLObjectMapper .readBatchedGraphQLRequest (inputStream );
233
233
GraphQLBatchedInvocationInput batchedInvocationInput =
234
- invocationInputFactory .create (configuration .getContextSetting (), requests , request , response );
234
+ invocationInputFactory .create (configuration .getContextSetting (), requests , request , response );
235
235
queryBatched (queryInvoker , batchedInvocationInput , request , response , configuration );
236
236
} else {
237
237
query (queryInvoker , graphQLObjectMapper , invocationInputFactory .create (graphQLObjectMapper .readGraphQLRequest (inputStream ), request , response ), request , response );
@@ -244,9 +244,9 @@ public void init() {
244
244
};
245
245
}
246
246
247
- private static InputStream asMarkableInputStream (InputStream inputStream ) {
247
+ private InputStream asMarkableInputStream (InputStream inputStream ) {
248
248
if (!inputStream .markSupported ()) {
249
- inputStream = new BufferedInputStream (inputStream );
249
+ return new BufferedInputStream (inputStream );
250
250
}
251
251
return inputStream ;
252
252
}
@@ -409,7 +409,7 @@ private void queryBatched(GraphQLQueryInvoker queryInvoker, GraphQLBatchedInvoca
409
409
BatchInputPreProcessResult batchInputPreProcessResult = batchInputPreProcessor .preProcessBatch (batchedInvocationInput , request , response );
410
410
if (batchInputPreProcessResult .isExecutable ()) {
411
411
List <ExecutionResult > results = queryInvoker .query (batchInputPreProcessResult .getBatchedInvocationInput ().getExecutionInputs (),
412
- contextSetting );
412
+ contextSetting );
413
413
response .setContentType (AbstractGraphQLHttpServlet .APPLICATION_JSON_UTF8 );
414
414
response .setStatus (AbstractGraphQLHttpServlet .STATUS_OK );
415
415
Writer writer = response .getWriter ();
0 commit comments