/*
 * Copyright © 2018 Smoke Turner, LLC (contact@smoketurner.com)
 *
 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
 * in compliance with the License. You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software distributed under the License
 * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
 * or implied. See the License for the specific language governing permissions and limitations under
 * the License.
 */
package com.smoketurner.dropwizard.graphql;

import graphql.schema.GraphQLSchema;
import graphql.servlet.GraphQLQueryInvoker;
import graphql.servlet.SimpleGraphQLHttpServlet;
import io.dropwizard.Configuration;
import io.dropwizard.ConfiguredBundle;
import io.dropwizard.assets.AssetsBundle;
import io.dropwizard.setup.Bootstrap;
import io.dropwizard.setup.Environment;

public abstract class GraphQLBundle<C extends Configuration>
    implements ConfiguredBundle<C>, GraphQLConfiguration<C> {

  @Override
  public void initialize(Bootstrap<?> bootstrap) {
    bootstrap.addBundle(new AssetsBundle("/assets/", "/"));
  }

  @Override
  public void run(final C configuration, final Environment environment) throws Exception {
    final GraphQLFactory factory = getGraphQLFactory(configuration);

    final GraphQLSchema schema = factory.build();

    final GraphQLQueryInvoker queryInvoker =
        GraphQLQueryInvoker.newBuilder().withInstrumentation(factory.getInstrumentations()).build();

    final SimpleGraphQLHttpServlet servlet =
        SimpleGraphQLHttpServlet.newBuilder(schema).withQueryInvoker(queryInvoker).build();

    environment.servlets().addServlet("graphql", servlet).addMapping("/graphql", "/schema.json");
  }
}

@@ -129,16 +129,19 @@
 cense%22);
+%0A *
  you may
@@ -165,19 +165,16 @@
 e except
-%0A *
  in comp
@@ -197,16 +197,19 @@
 License.
+%0A *
  You may
@@ -246,16 +246,20 @@
 at%0A *%0A *
+    
  http://
@@ -367,16 +367,19 @@
 software
+%0A *
  distrib
@@ -400,19 +400,16 @@
  License
-%0A *
  is dist
@@ -436,16 +436,19 @@
 %22 BASIS,
+%0A *
  WITHOUT
@@ -500,19 +500,16 @@
  express
-%0A *
  or impl
@@ -512,16 +512,19 @@
 implied.
+%0A *
  See the
@@ -583,16 +583,19 @@
 ions and
+%0A *
  limitat
@@ -604,19 +604,16 @@
 ns under
-%0A *
  the Lic

Fix formatting