// Path: graphql-rest/src/main/java/org/objectstyle/graphql/rest/json/JacksonReaderWriter.java
// public class JacksonReaderWriter implements JsonReader, JsonWriter {
// 
//     private ObjectMapper sharedMapper;
//     private JsonFactory sharedFactory;
// 
//     public JacksonReaderWriter() {
// 
//         // fun Jackson API with circular dependencies ... so we create a mapper
//         // first, and grab implicitly created factory from it
//         this.sharedMapper = new ObjectMapper();
//         this.sharedFactory = sharedMapper.getFactory();
// 
//         // make sure mapper does not attempt closing streams it does not
//         // manage... why is this even a default in jackson?
//         sharedFactory.disable(Feature.AUTO_CLOSE_TARGET);
// 
//         // do not flush every time. why would we want to do that?
//         // this is having a HUGE impact on extrest serializers (5x speedup)
//         sharedMapper.disable(SerializationFeature.FLUSH_AFTER_WRITE_VALUE);
//     }
// 
//     private JsonNode parseJson(InputStream jsonStream) {
//         Objects.requireNonNull(jsonStream);
// 
//         try {
//             com.fasterxml.jackson.core.JsonParser parser = sharedFactory.createParser(jsonStream);
//             return new ObjectMapper().readTree(parser);
//         } catch (IOException e) {
//             throw new GraphQLRestException(Status.BAD_REQUEST, "Error parsing JSON", e);
//         }
//     }
// 
//     @Override
//     public <T> T read(Class<T> type, InputStream jsonStream) {
//         JsonNode jsonNode = parseJson(jsonStream);
//         try {
//             return new ObjectMapper().readValue(new TreeTraversingParser(jsonNode), type);
//         } catch (IOException e) {
//             throw new GraphQLRestException(Status.BAD_REQUEST, "Error mapping JSON to object", e);
//         }
//     }
// 
//     @Override
//     public void write(OutputStream out, JacksonWriterDelegate delegate) {
//         // TODO: UTF-8 is hardcoded...
//         try (JsonGenerator generator = sharedFactory.createGenerator(out, JsonEncoding.UTF8)) {
//             delegate.write(generator);
//         } catch (IOException e) {
//             throw new GraphQLRestException(Status.INTERNAL_SERVER_ERROR, "Error writing JSON", e);
//         }
//     }
// 
// }
// 
// Path: graphql-rest/src/main/java/org/objectstyle/graphql/rest/json/JsonWriter.java
// public interface JsonWriter {
// 
//     void write(OutputStream out, JacksonWriterDelegate delegate);
// }


import java.io.IOException;
import java.io.OutputStream;
import java.lang.annotation.Annotation;
import java.lang.reflect.Type;
import javax.inject.Singleton;
import javax.ws.rs.WebApplicationException;
import javax.ws.rs.core.Configuration;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.MultivaluedMap;
import javax.ws.rs.ext.MessageBodyWriter;
import javax.ws.rs.ext.Provider;
import org.objectstyle.graphql.rest.json.JacksonReaderWriter;
import org.objectstyle.graphql.rest.json.JsonWriter;
import graphql.ExecutionResult;
package org.objectstyle.graphql.rest.provider;





@Provider
@Singleton
public class ExecutionResultWriter implements MessageBodyWriter<ExecutionResult> {
    @Context
    Configuration config;

    @Override
    public long getSize(ExecutionResult t, Class<?> type, Type genericType, Annotation[] annotations,
                        MediaType mediaType) {
        return -1;
    }

    @Override
    public boolean isWriteable(Class<?> type, Type genericType, Annotation[] annotations, MediaType mediaType) {
// Path: graphql-rest/src/main/java/org/objectstyle/graphql/rest/json/JacksonReaderWriter.java
// public class JacksonReaderWriter implements JsonReader, JsonWriter {
// 
//     private ObjectMapper sharedMapper;
//     private JsonFactory sharedFactory;
// 
//     public JacksonReaderWriter() {
// 
//         // fun Jackson API with circular dependencies ... so we create a mapper
//         // first, and grab implicitly created factory from it
//         this.sharedMapper = new ObjectMapper();
//         this.sharedFactory = sharedMapper.getFactory();
// 
//         // make sure mapper does not attempt closing streams it does not
//         // manage... why is this even a default in jackson?
//         sharedFactory.disable(Feature.AUTO_CLOSE_TARGET);
// 
//         // do not flush every time. why would we want to do that?
//         // this is having a HUGE impact on extrest serializers (5x speedup)
//         sharedMapper.disable(SerializationFeature.FLUSH_AFTER_WRITE_VALUE);
//     }
// 
//     private JsonNode parseJson(InputStream jsonStream) {
//         Objects.requireNonNull(jsonStream);
// 
//         try {
//             com.fasterxml.jackson.core.JsonParser parser = sharedFactory.createParser(jsonStream);
//             return new ObjectMapper().readTree(parser);
//         } catch (IOException e) {
//             throw new GraphQLRestException(Status.BAD_REQUEST, "Error parsing JSON", e);
//         }
//     }
// 
//     @Override
//     public <T> T read(Class<T> type, InputStream jsonStream) {
//         JsonNode jsonNode = parseJson(jsonStream);
//         try {
//             return new ObjectMapper().readValue(new TreeTraversingParser(jsonNode), type);
//         } catch (IOException e) {
//             throw new GraphQLRestException(Status.BAD_REQUEST, "Error mapping JSON to object", e);
//         }
//     }
// 
//     @Override
//     public void write(OutputStream out, JacksonWriterDelegate delegate) {
//         // TODO: UTF-8 is hardcoded...
//         try (JsonGenerator generator = sharedFactory.createGenerator(out, JsonEncoding.UTF8)) {
//             delegate.write(generator);
//         } catch (IOException e) {
//             throw new GraphQLRestException(Status.INTERNAL_SERVER_ERROR, "Error writing JSON", e);
//         }
//     }
// 
// }
// 
// Path: graphql-rest/src/main/java/org/objectstyle/graphql/rest/json/JsonWriter.java
// public interface JsonWriter {
// 
//     void write(OutputStream out, JacksonWriterDelegate delegate);
// }


// Path: graphql-rest/src/main/java/org/objectstyle/graphql/rest/provider/ExecutionResultWriter.java
import java.io.IOException;
import java.io.OutputStream;
import java.lang.annotation.Annotation;
import java.lang.reflect.Type;
import javax.inject.Singleton;
import javax.ws.rs.WebApplicationException;
import javax.ws.rs.core.Configuration;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.MultivaluedMap;
import javax.ws.rs.ext.MessageBodyWriter;
import javax.ws.rs.ext.Provider;
import org.objectstyle.graphql.rest.json.JacksonReaderWriter;
import org.objectstyle.graphql.rest.json.JsonWriter;
import graphql.ExecutionResult;

package org.objectstyle.graphql.rest.provider;





@Provider
@Singleton
public class ExecutionResultWriter implements MessageBodyWriter<ExecutionResult> {
    @Context
    Configuration config;

    @Override
    public long getSize(ExecutionResult t, Class<?> type, Type genericType, Annotation[] annotations,
                        MediaType mediaType) {
        return -1;
    }

    @Override
    public boolean isWriteable(Class<?> type, Type genericType, Annotation[] annotations, MediaType mediaType) {
        return ExecutionResult.class.isAssignableFrom(type);