Dropwizard GraphQL Bundle

Build Status Maven Central GitHub license Become a Patron

A bundle for providing GraphQL API endpoints in Dropwizard applications.

Dependency Info

<dependency>
    <groupId>com.smoketurner.dropwizard</groupId>
    <artifactId>graphql-core</artifactId>
    <version>2.0.7-1</version>
</dependency>

Usage

Add a GraphQLBundle to your Application class.

@Override
public void initialize(Bootstrap<MyConfiguration> bootstrap) {
    // ...
    final GraphQLBundle<HelloWorldConfiguration> bundle = new GraphQLBundle<HelloWorldConfiguration>() {
        @Override
        public GraphQLFactory getGraphQLFactory(HelloWorldConfiguration configuration) {

            final GraphQLFactory factory = configuration.getGraphQLFactory();
            // the RuntimeWiring must be configured prior to the run()
            // methods being called so the schema is connected properly.
            factory.setRuntimeWiring(buildWiring(configuration));
            return factory;
        }
    };
    bootstrap.addBundle(bundle);
}

Example Application

This bundle includes a modified version of the HelloWorldApplication from Dropwizard's Getting Started documentation.

You can execute this application on your local machine then running:

./mvnw clean package
java -jar graphql-example/target/graphql-example-2.0.7-2-SNAPSHOT.jar server graphql-example/hello-world.yml

This will start the application on port 8080 with a GraphQL Playground interface for exploring the API.

Support

Please file bug reports and feature requests in GitHub issues.

License

Copyright (c) 2020 Smoke Turner, LLC

This library is licensed under the Apache License, Version 2.0.

See http://www.apache.org/licenses/LICENSE-2.0.html or the LICENSE file in this repository for the full license text.