// Path: bootique-graphql/src/main/java/org/objectstyle/bootique/graphql/jaxrs/provider/BQGraphQLRestExceptionMapper.java
// @Provider
// @Singleton
// public class BQGraphQLRestExceptionMapper implements ExceptionMapper<BQGraphQLRestException> {
// 
// 	private static final Logger LOGGER = LoggerFactory.getLogger(BQGraphQLRestExceptionMapper.class);
// 
// 	@Override
// 	public Response toResponse(BQGraphQLRestException exception) {
// 
// 		String message = exception.getMessage();
// 		Status status = exception.getStatus();
// 
// 		if (LOGGER.isInfoEnabled()) {
// 			StringBuilder log = new StringBuilder();
// 			log.append(status.getStatusCode()).append(" ").append(status.getReasonPhrase());
// 
// 			if (message != null) {
// 				log.append(" (").append(message).append(")");
// 			}
// 
// 			if (exception.getCause() != null && exception.getCause().getMessage() != null) {
// 				log.append(" [cause: ").append(exception.getCause().getMessage()).append("]");
// 			}
// 
// 			// include stack trace in debug mode...
// 			if (LOGGER.isDebugEnabled()) {
// 				LOGGER.debug(log.toString(), exception);
// 			} else {
// 				LOGGER.info(log.toString());
// 			}
// 		}
// 
// 		return Response.status(status).entity(new MessageResponse(message)).type(MediaType.APPLICATION_JSON_TYPE)
// 				.build();
// 	}
// }
// 
// Path: bootique-graphql/src/main/java/org/objectstyle/bootique/graphql/jaxrs/provider/ExecutionResultWriter.java
// @Provider
// @Singleton
// public class ExecutionResultWriter implements MessageBodyWriter<ExecutionResult> {
// 
// 	@Inject
// 	private JsonWriter writer;
// 
// 	@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);
// 	}
// 
// 	@Override
// 	public void writeTo(ExecutionResult t, Class<?> type, Type genericType, Annotation[] annotations,
// 			MediaType mediaType, MultivaluedMap<String, Object> httpHeaders, OutputStream entityStream)
// 					throws IOException, WebApplicationException {
// 
// 		writer.write(entityStream, generator -> {
// 
// 			generator.writeStartObject();
// 
// 			// TODO: is it ok to rely on default serialization of data and
// 			// errors?
// 
// 			if (t.getData() != null) {
// 				generator.writeObjectField("data", t.getData());
// 			}
// 
// 			if (t.getErrors() != null && !t.getErrors().isEmpty()) {
// 				generator.writeObjectField("errors", t.getErrors());
// 			}
// 
// 			generator.writeEndObject();
// 
// 		});
// 	}
// }
// 
// Path: bootique-graphql/src/main/java/org/objectstyle/bootique/graphql/jaxrs/provider/GraphiQLRestQueryReader.java
// @Singleton
// @Provider
// public class GraphiQLRestQueryReader implements MessageBodyReader<GraphQLRestQuery> {
// 
// 	@Inject
// 	private JsonReader jsonParser;
// 
// 	@Override
// 	public boolean isReadable(Class<?> type, Type genericType, Annotation[] annotations, MediaType mediaType) {
// 		return GraphQLRestQuery.class.isAssignableFrom(type);
// 	}
// 
// 	@Override
// 	public GraphQLRestQuery readFrom(Class<GraphQLRestQuery> type, Type genericType, Annotation[] annotations,
// 			MediaType mediaType, MultivaluedMap<String, String> httpHeaders, InputStream entityStream)
// 					throws IOException, WebApplicationException {
// 
// 		return jsonParser.read(GraphQLRestQuery.class, entityStream);
// 	}
// }
// 
// Path: bootique-graphql/src/main/java/org/objectstyle/bootique/graphql/jaxrs/provider/MessageResponseWriter.java
// public class MessageResponseWriter implements MessageBodyWriter<MessageResponse> {
// 
// 	@Inject
// 	private JsonWriter writer;
// 
// 	@Override
// 	public long getSize(MessageResponse t, Class<?> type, Type genericType, Annotation[] annotations,
// 			MediaType mediaType) {
// 		return -1;
// 	}
// 
// 	@Override
// 	public boolean isWriteable(Class<?> type, Type genericType, Annotation[] annotations, MediaType mediaType) {
// 		return MessageResponse.class.isAssignableFrom(type);
// 	}
// 
// 	@Override
// 	public void writeTo(MessageResponse t, Class<?> type, Type genericType, Annotation[] annotations,
// 			MediaType mediaType, MultivaluedMap<String, Object> httpHeaders, OutputStream entityStream)
// 					throws IOException {
// 
// 		writer.write(entityStream, generator -> {
// 			generator.writeStartObject();
// 
// 			if (t.getMessage() != null) {
// 				generator.writeStringField("message", t.getMessage());
// 			}
// 
// 			generator.writeEndObject();
// 		});
// 
// 	}
// 
// }


import javax.ws.rs.core.Feature;
import javax.ws.rs.core.FeatureContext;
import org.objectstyle.bootique.graphql.jaxrs.provider.BQGraphQLRestExceptionMapper;
import org.objectstyle.bootique.graphql.jaxrs.provider.ExecutionResultWriter;
import org.objectstyle.bootique.graphql.jaxrs.provider.GraphiQLRestQueryReader;
import org.objectstyle.bootique.graphql.jaxrs.provider.MessageResponseWriter;
package org.objectstyle.bootique.graphql.jaxrs;



/**
 * Loads JAX-RS extensions for GraphQL processing.
 */
public class GraphQLFeature implements Feature {

	@Override
	public boolean configure(FeatureContext context) {
// Path: bootique-graphql/src/main/java/org/objectstyle/bootique/graphql/jaxrs/provider/BQGraphQLRestExceptionMapper.java
// @Provider
// @Singleton
// public class BQGraphQLRestExceptionMapper implements ExceptionMapper<BQGraphQLRestException> {
// 
// 	private static final Logger LOGGER = LoggerFactory.getLogger(BQGraphQLRestExceptionMapper.class);
// 
// 	@Override
// 	public Response toResponse(BQGraphQLRestException exception) {
// 
// 		String message = exception.getMessage();
// 		Status status = exception.getStatus();
// 
// 		if (LOGGER.isInfoEnabled()) {
// 			StringBuilder log = new StringBuilder();
// 			log.append(status.getStatusCode()).append(" ").append(status.getReasonPhrase());
// 
// 			if (message != null) {
// 				log.append(" (").append(message).append(")");
// 			}
// 
// 			if (exception.getCause() != null && exception.getCause().getMessage() != null) {
// 				log.append(" [cause: ").append(exception.getCause().getMessage()).append("]");
// 			}
// 
// 			// include stack trace in debug mode...
// 			if (LOGGER.isDebugEnabled()) {
// 				LOGGER.debug(log.toString(), exception);
// 			} else {
// 				LOGGER.info(log.toString());
// 			}
// 		}
// 
// 		return Response.status(status).entity(new MessageResponse(message)).type(MediaType.APPLICATION_JSON_TYPE)
// 				.build();
// 	}
// }
// 
// Path: bootique-graphql/src/main/java/org/objectstyle/bootique/graphql/jaxrs/provider/ExecutionResultWriter.java
// @Provider
// @Singleton
// public class ExecutionResultWriter implements MessageBodyWriter<ExecutionResult> {
// 
// 	@Inject
// 	private JsonWriter writer;
// 
// 	@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);
// 	}
// 
// 	@Override
// 	public void writeTo(ExecutionResult t, Class<?> type, Type genericType, Annotation[] annotations,
// 			MediaType mediaType, MultivaluedMap<String, Object> httpHeaders, OutputStream entityStream)
// 					throws IOException, WebApplicationException {
// 
// 		writer.write(entityStream, generator -> {
// 
// 			generator.writeStartObject();
// 
// 			// TODO: is it ok to rely on default serialization of data and
// 			// errors?
// 
// 			if (t.getData() != null) {
// 				generator.writeObjectField("data", t.getData());
// 			}
// 
// 			if (t.getErrors() != null && !t.getErrors().isEmpty()) {
// 				generator.writeObjectField("errors", t.getErrors());
// 			}
// 
// 			generator.writeEndObject();
// 
// 		});
// 	}
// }
// 
// Path: bootique-graphql/src/main/java/org/objectstyle/bootique/graphql/jaxrs/provider/GraphiQLRestQueryReader.java
// @Singleton
// @Provider
// public class GraphiQLRestQueryReader implements MessageBodyReader<GraphQLRestQuery> {
// 
// 	@Inject
// 	private JsonReader jsonParser;
// 
// 	@Override
// 	public boolean isReadable(Class<?> type, Type genericType, Annotation[] annotations, MediaType mediaType) {
// 		return GraphQLRestQuery.class.isAssignableFrom(type);
// 	}
// 
// 	@Override
// 	public GraphQLRestQuery readFrom(Class<GraphQLRestQuery> type, Type genericType, Annotation[] annotations,
// 			MediaType mediaType, MultivaluedMap<String, String> httpHeaders, InputStream entityStream)
// 					throws IOException, WebApplicationException {
// 
// 		return jsonParser.read(GraphQLRestQuery.class, entityStream);
// 	}
// }
// 
// Path: bootique-graphql/src/main/java/org/objectstyle/bootique/graphql/jaxrs/provider/MessageResponseWriter.java
// public class MessageResponseWriter implements MessageBodyWriter<MessageResponse> {
// 
// 	@Inject
// 	private JsonWriter writer;
// 
// 	@Override
// 	public long getSize(MessageResponse t, Class<?> type, Type genericType, Annotation[] annotations,
// 			MediaType mediaType) {
// 		return -1;
// 	}
// 
// 	@Override
// 	public boolean isWriteable(Class<?> type, Type genericType, Annotation[] annotations, MediaType mediaType) {
// 		return MessageResponse.class.isAssignableFrom(type);
// 	}
// 
// 	@Override
// 	public void writeTo(MessageResponse t, Class<?> type, Type genericType, Annotation[] annotations,
// 			MediaType mediaType, MultivaluedMap<String, Object> httpHeaders, OutputStream entityStream)
// 					throws IOException {
// 
// 		writer.write(entityStream, generator -> {
// 			generator.writeStartObject();
// 
// 			if (t.getMessage() != null) {
// 				generator.writeStringField("message", t.getMessage());
// 			}
// 
// 			generator.writeEndObject();
// 		});
// 
// 	}
// 
// }


// Path: bootique-graphql/src/main/java/org/objectstyle/bootique/graphql/jaxrs/GraphQLFeature.java
import javax.ws.rs.core.Feature;
import javax.ws.rs.core.FeatureContext;
import org.objectstyle.bootique.graphql.jaxrs.provider.BQGraphQLRestExceptionMapper;
import org.objectstyle.bootique.graphql.jaxrs.provider.ExecutionResultWriter;
import org.objectstyle.bootique.graphql.jaxrs.provider.GraphiQLRestQueryReader;
import org.objectstyle.bootique.graphql.jaxrs.provider.MessageResponseWriter;

package org.objectstyle.bootique.graphql.jaxrs;



/**
 * Loads JAX-RS extensions for GraphQL processing.
 */
public class GraphQLFeature implements Feature {

	@Override
	public boolean configure(FeatureContext context) {
		context.register(MessageResponseWriter.class);