2020import java .util .Map ;
2121import java .util .function .Supplier ;
2222
23+ import static java .util .stream .Collectors .toList ;
24+
2325/**
2426 * @author Andrew Potter
2527 */
2628public class GraphQLObjectMapper {
2729 private static final TypeReference <Map <String , List <String >>>
28- MULTIPART_MAP_TYPE_REFERENCE = new TypeReference <Map <String , List <String >>>() {
29- };
30+ MULTIPART_MAP_TYPE_REFERENCE = new TypeReference <Map <String , List <String >>>() {
31+ };
3032 private final ObjectMapperProvider objectMapperProvider ;
3133 private final Supplier <GraphQLErrorHandler > graphQLErrorHandlerSupplier ;
3234
@@ -41,7 +43,7 @@ protected GraphQLObjectMapper(ObjectMapperProvider objectMapperProvider, Supplie
4143 public ObjectMapper getJacksonMapper () {
4244 ObjectMapper result = mapper ;
4345 if (result == null ) { // First check (no locking)
44- synchronized (this ) {
46+ synchronized (this ) {
4547 result = mapper ;
4648 if (result == null ) { // Second check (with locking)
4749 mapper = result = objectMapperProvider .provide ();
@@ -107,7 +109,7 @@ public ExecutionResult sanitizeErrors(ExecutionResult executionResult) {
107109 List <GraphQLError > errors = executionResult .getErrors ();
108110
109111 GraphQLErrorHandler errorHandler = graphQLErrorHandlerSupplier .get ();
110- if (errorHandler .errorsPresent (errors )) {
112+ if (errorHandler .errorsPresent (errors )) {
111113 errors = errorHandler .processErrors (errors );
112114 } else {
113115 errors = null ;
@@ -128,14 +130,14 @@ public Map<String, Object> convertSanitizedExecutionResult(ExecutionResult execu
128130 final Map <String , Object > result = new LinkedHashMap <>();
129131
130132 if (areErrorsPresent (executionResult )) {
131- result .put ("errors" , executionResult .getErrors ());
133+ result .put ("errors" , executionResult .getErrors (). stream (). map ( err -> err . toSpecification ()). collect ( toList ()) );
132134 }
133135
134- if (executionResult .getExtensions () != null && !executionResult .getExtensions ().isEmpty ()){
136+ if (executionResult .getExtensions () != null && !executionResult .getExtensions ().isEmpty ()) {
135137 result .put ("extensions" , executionResult .getExtensions ());
136138 }
137139
138- if (includeData ) {
140+ if (includeData ) {
139141 result .put ("data" , executionResult .getData ());
140142 }
141143
@@ -150,7 +152,7 @@ public Map<String, Object> deserializeVariables(String variables) {
150152 }
151153 }
152154
153- public Map <String ,List <String >> deserializeMultipartMap (Part part ) {
155+ public Map <String , List <String >> deserializeMultipartMap (Part part ) {
154156 try {
155157 return getJacksonMapper ().readValue (part .getInputStream (), MULTIPART_MAP_TYPE_REFERENCE );
156158 } catch (IOException e ) {
0 commit comments