{"id":13770283,"url":"https://github.com/smoketurner/dropwizard-graphql","last_synced_at":"2025-04-13T23:33:08.918Z","repository":{"id":13489558,"uuid":"74578703","full_name":"smoketurner/dropwizard-graphql","owner":"smoketurner","description":"Dropwizard GraphQL Bundle","archived":false,"fork":false,"pushed_at":"2024-04-29T07:02:40.000Z","size":1172,"stargazers_count":55,"open_issues_count":2,"forks_count":18,"subscribers_count":4,"default_branch":"4.0.x","last_synced_at":"2024-05-19T14:33:16.165Z","etag":null,"topics":["dropwizard","dropwizard-graphql","graphql","java"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/smoketurner.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":"jplock","patreon":"jplock","open_collective":null,"ko_fi":null,"tidelift":null,"custom":null}},"created_at":"2016-11-23T13:20:08.000Z","updated_at":"2024-06-06T01:58:15.816Z","dependencies_parsed_at":"2024-03-04T01:42:28.205Z","dependency_job_id":"d0bf64d8-4d67-4f7d-ae98-409bda9addbc","html_url":"https://github.com/smoketurner/dropwizard-graphql","commit_stats":null,"previous_names":[],"tags_count":34,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/smoketurner%2Fdropwizard-graphql","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/smoketurner%2Fdropwizard-graphql/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/smoketurner%2Fdropwizard-graphql/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/smoketurner%2Fdropwizard-graphql/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/smoketurner","download_url":"https://codeload.github.com/smoketurner/dropwizard-graphql/tar.gz/refs/heads/4.0.x","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248797126,"owners_count":21163089,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["dropwizard","dropwizard-graphql","graphql","java"],"created_at":"2024-08-03T17:00:35.922Z","updated_at":"2025-04-13T23:33:08.287Z","avatar_url":"https://github.com/smoketurner.png","language":"Java","funding_links":["https://github.com/sponsors/jplock","https://patreon.com/jplock","https://www.patreon.com/bePatron?u=9567343"],"categories":["Exposing a Schema","Open Source"],"sub_categories":["Code First","Eclipse"],"readme":"Dropwizard GraphQL Bundle\n========================\n[![Build Status](https://travis-ci.org/smoketurner/dropwizard-graphql.svg?branch=master)](https://travis-ci.org/smoketurner/dropwizard-graphql)\n[![Maven Central](https://img.shields.io/maven-central/v/com.smoketurner.dropwizard/dropwizard-graphql.svg?style=flat-square)](https://maven-badges.herokuapp.com/maven-central/com.smoketurner.dropwizard/dropwizard-graphql/)\n[![GitHub license](https://img.shields.io/github/license/smoketurner/dropwizard-graphql.svg?style=flat-square)](https://github.com/smoketurner/dropwizard-graphql/tree/master)\n[![Become a Patron](https://img.shields.io/badge/Patron-Patreon-red.svg)](https://www.patreon.com/bePatron?u=9567343)\n\nA bundle for providing [GraphQL](http://graphql.org) API endpoints in Dropwizard applications.\n\nDependency Info\n---------------\n```xml\n\u003cdependency\u003e\n    \u003cgroupId\u003ecom.smoketurner.dropwizard\u003c/groupId\u003e\n    \u003cartifactId\u003egraphql-core\u003c/artifactId\u003e\n    \u003cversion\u003e2.0.7-1\u003c/version\u003e\n\u003c/dependency\u003e\n```\n\nUsage\n-----\nAdd a `GraphQLBundle` to your [Application](https://javadoc.io/doc/io.dropwizard/dropwizard-project/latest/io/dropwizard/Application.html) class.\n\n```java\n@Override\npublic void initialize(Bootstrap\u003cMyConfiguration\u003e bootstrap) {\n    // ...\n    final GraphQLBundle\u003cHelloWorldConfiguration\u003e bundle = new GraphQLBundle\u003cHelloWorldConfiguration\u003e() {\n        @Override\n        public GraphQLFactory getGraphQLFactory(HelloWorldConfiguration configuration) {\n\n            final GraphQLFactory factory = configuration.getGraphQLFactory();\n            // the RuntimeWiring must be configured prior to the run()\n            // methods being called so the schema is connected properly.\n            factory.setRuntimeWiring(buildWiring(configuration));\n            return factory;\n        }\n    };\n    bootstrap.addBundle(bundle);\n}\n```\n## Adding GraphQL along with REST API Endpoints in Dropwizard\nTo use GraphQL along with REST APIs in dropwizard you need to change the root path in the bundle which we add\nin the main class of dropwizard. Otherwise the bundle may conflict with root path of REST API's.\n\nYou need to add the root path by overiding the ```initialize``` method in GraphQL bundle.\n```\n@Override\n  public void initialize(Bootstrap\u003c?\u003e bootstrap) {\n    bootstrap.addBundle(new AssetsBundle(\"/assets\", \"/\", \"index.htm\", \"graphql-playground\"));\n  }\n``` \nThis is the default ```initialize``` method in GraphQL bundle.\nIf you want to expose your GraphQL endpoint at ``localhost:8080/graphql`` then you have to change\nthe path in the ```AssetBundle``` constructor.\n\nNow the overriden method which we add while adding bundle is \n\n```\n@Override\n  public void initialize(Bootstrap\u003c?\u003e bootstrap) {\n    bootstrap.addBundle(new AssetsBundle(\"/assets\", \"/graphql\", \"index.htm\", \"graphql-playground\"));\n    //graphql is the endpoint which is concerned with graphql\n  }\n```  \nThis avoids conflict between REST API and GraphQL endpoints.\n\nWhen we start the dropwizard server the GraphQL playground looks for GraphQL schema.GraphQL dropwizard creates a \nschema.json file after processing our GraphQL schema. The GraphQL playground looks out for this schema. It looks out \nat ```/graphql``` from the GraphQL endpoint.If you wish to change where the GraphQL playground looks for this schema file\nthen you may override the ```run``` method in GraphQL bundle class.\n\nIf we want our schema.json to be available at ```localhost:8080/graphql/query``` then the overridden method should like this.\n```\n@Override\n  public void run(final C configuration, final Environment environment) throws Exception {\n    final GraphQLFactory factory = getGraphQLFactory(configuration);\n\n    final PreparsedDocumentProvider provider =\n        new CachingPreparsedDocumentProvider(factory.getQueryCache(), environment.metrics());\n\n    final GraphQLSchema schema = factory.build();\n\n    final GraphQLQueryInvoker queryInvoker =\n        GraphQLQueryInvoker.newBuilder()\n            .withPreparsedDocumentProvider(provider)\n            .withInstrumentation(factory.getInstrumentations())\n            .build();\n\n    final graphql.kickstart.servlet.GraphQLConfiguration config =\n        graphql.kickstart.servlet.GraphQLConfiguration.with(schema).with(queryInvoker).build();\n\n    final GraphQLHttpServlet servlet = GraphQLHttpServlet.with(config);\n\n    environment.servlets().addServlet(\"graphql\", servlet).addMapping(\"/query\", \"/schema.json\");\n  }\n```\n\nExample Application\n-------------------\nThis bundle includes a modified version of the `HelloWorldApplication` from Dropwizard's [Getting Started](https://www.dropwizard.io/en/latest/getting-started.html) documentation.\n\nYou can execute this application on your local machine then running:\n\n```\n./mvnw clean package\njava -jar graphql-example/target/graphql-example-2.0.7-2-SNAPSHOT.jar server graphql-example/hello-world.yml\n```\n\nThis will start the application on port `8080` with a [GraphQL Playground](https://github.com/prisma-labs/graphql-playground) interface for exploring the API.\n\nSupport\n-------\nPlease file bug reports and feature requests in [GitHub issues](https://github.com/smoketurner/dropwizard-graphql/issues).\n\nLicense\n-------\nCopyright (c) 2020 Smoke Turner, LLC\n\nThis library is licensed under the Apache License, Version 2.0.\n\nSee http://www.apache.org/licenses/LICENSE-2.0.html or the [LICENSE](LICENSE) file in this repository for the full license text.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsmoketurner%2Fdropwizard-graphql","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsmoketurner%2Fdropwizard-graphql","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsmoketurner%2Fdropwizard-graphql/lists"}