@@ -364,7 +364,7 @@ private void query(GraphQLQueryInvoker queryInvoker, GraphQLObjectMapper graphQL
364364 if (!(result .getData () instanceof Publisher || isDeferred )) {
365365 resp .setContentType (APPLICATION_JSON_UTF8 );
366366 resp .setStatus (STATUS_OK );
367- resp .getWriter (). write ( graphQLObjectMapper . serializeResultAsJson ( result ) );
367+ graphQLObjectMapper . serializeResultAsJson ( resp .getWriter (), result );
368368 } else {
369369 if (req == null ) {
370370 throw new IllegalStateException ("Http servlet request can not be null" );
@@ -414,7 +414,7 @@ private void queryBatched(GraphQLQueryInvoker queryInvoker, GraphQLBatchedInvoca
414414 writer .write ("[" );
415415 GraphQLObjectMapper graphQLObjectMapper = configuration .getObjectMapper ();
416416 while (executionInputIterator .hasNext ()) {
417- writer . write ( graphQLObjectMapper .serializeResultAsJson (executionInputIterator .next () ));
417+ graphQLObjectMapper .serializeResultAsJson (writer , executionInputIterator .next ());
418418 if (executionInputIterator .hasNext ()) {
419419 writer .write ("," );
420420 }
@@ -558,7 +558,9 @@ public void onSubscribe(Subscription subscription) {
558558 public void onNext (ExecutionResult executionResult ) {
559559 try {
560560 Writer writer = asyncContext .getResponse ().getWriter ();
561- writer .write ("data: " + graphQLObjectMapper .serializeResultAsJson (executionResult ) + "\n \n " );
561+ writer .write ("data: " );
562+ graphQLObjectMapper .serializeResultAsJson (writer , executionResult );
563+ writer .write ("\n \n " );
562564 writer .flush ();
563565 subscriptionRef .get ().request (1 );
564566 } catch (IOException ignored ) {
0 commit comments