{"id":14976141,"url":"https://github.com/yarinvak/graphql-spring-annotations","last_synced_at":"2025-10-27T18:30:40.601Z","repository":{"id":99611617,"uuid":"214829991","full_name":"yarinvak/graphql-spring-annotations","owner":"yarinvak","description":"a starter for a graphql-java-annotations in spring","archived":false,"fork":false,"pushed_at":"2019-10-21T12:34:17.000Z","size":119,"stargazers_count":11,"open_issues_count":1,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2024-09-28T21:41:17.162Z","etag":null,"topics":["graphql","graphql-java-annotations","graphql-schema","graphql-server","graphql-spring-boot"],"latest_commit_sha":null,"homepage":null,"language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/yarinvak.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-10-13T13:59:08.000Z","updated_at":"2024-07-18T16:50:14.000Z","dependencies_parsed_at":"2023-04-17T07:38:43.523Z","dependency_job_id":null,"html_url":"https://github.com/yarinvak/graphql-spring-annotations","commit_stats":{"total_commits":46,"total_committers":1,"mean_commits":46.0,"dds":0.0,"last_synced_commit":"2b55fc626b8d2e16c222d5982b1363d4042cc17a"},"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yarinvak%2Fgraphql-spring-annotations","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yarinvak%2Fgraphql-spring-annotations/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yarinvak%2Fgraphql-spring-annotations/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yarinvak%2Fgraphql-spring-annotations/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/yarinvak","download_url":"https://codeload.github.com/yarinvak/graphql-spring-annotations/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":219860762,"owners_count":16556011,"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":["graphql","graphql-java-annotations","graphql-schema","graphql-server","graphql-spring-boot"],"created_at":"2024-09-24T13:53:22.892Z","updated_at":"2025-10-27T18:30:35.290Z","avatar_url":"https://github.com/yarinvak.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# graphql-spring-annotations\n[ ![Download](https://api.bintray.com/packages/yarinvak/graphql-spring-annotations/graphql-spring-annotations/images/download.svg) ](https://bintray.com/yarinvak/graphql-spring-annotations/graphql-spring-annotations/_latestVersion)\n[![Build Status](https://travis-ci.com/yarinvak/graphql-spring-annotations.svg?branch=master)](https://travis-ci.com/yarinvak/graphql-spring-annotations)\n\n[graphql-java-annotations](https://github.com/Enigmatis/graphql-java-annotations) is a great library for creating a graphql schema based on POJOs and java annotations.\nIt simplifies the graphql schema creation and does not require creating a separated graphql schema and java types.\n\ngraphql-spring-annotations is based on [graphql-java-annotations](https://github.com/Enigmatis/graphql-java-annotations) and [graphql-spring-boot](https://github.com/graphql-java-kickstart/graphql-spring-boot), and let\nyou create a spring server for you graphql application, using spring annotations to create your schema.\n\n## How to use\n\nfirst, add the following dependecies to your build.gradle:\n\n```$xslt\ndependencies {\n    compile \"io.github.enigmatis:graphql-spring-annotations:0.1.5\"\n}\n``` \n\nThen, create your main ``Application`` class:\n\n```java\npackage myAppPckg;\n\nimport org.springframework.boot.SpringApplication;\nimport org.springframework.boot.autoconfigure.SpringBootApplication;\n\n@SpringBootApplication(scanBasePackages = {\"springAnno\",\n\"myAppPckg\"})\npublic class Application {\n    public static void main(String[] args) {\n        SpringApplication.run(Application.class, args);\n    }\n}\n```\n\nNotice that in your ``scanBasePackages`` you must supply `springAnno` package, which comes from the ``graphql-spring-boot`` project.\nYou also have to scan your package if it contains spring components.\n\nNow you have to create your schema types.\n\nLets begin with the Query type definition (via graphql-java-annotations syntax):\n\n```java\n@Component\npublic class Query implements QueryRoot {\n     @GraphQLField\n     @GraphQLInvokeDetached\n     public String helloWorld(){\n         return \"helloWorld\";\n     }   \n}\n```\n\nThis is a standard type definition using graphql-java-annotations syntax. The only difference is that we add the `@Component` annotation,\nand implement `QueryRoot` interface (then it will be injected automatically into the schema).\n\nYou can create your `Mutation` and `Subscription` type in the same way: a graphql-java-annotations syntax, `@Component` annotation on top of the class, and implementing the `MutationRoot` or `SubscriptionRoot` interfaces accordingly.\n\n### Directives\n\nFor directives to be added to your schema, you only need to put the `@GraphQLDirectiveDefinition` annotation (it is required by graphql-java-annotations) and your directives will be injected to the schema. No `@Component` is required.\n\nYou also have to assign the configuration `directives.package` in your properties file, with the value being the package where your directives at.\n\nFor example:\n\n```java\n@GraphQLName(\"upper\")\n@GraphQLDescription(\"upper\")\n@GraphQLDirectiveDefinition(wiring= UpperDirectiveWiring.class)\n@DirectiveLocations({Introspection.DirectiveLocation.FIELD_DEFINITION, Introspection.DirectiveLocation.ARGUMENT_DEFINITION})\npublic class UpperDirectiveDefinition {\n    private boolean isActive = true;\n}\n```\n\n### Additional Types\n\nIf you have an additional graphql types that cannot be refered directly from the root types (for example, if you have a field in Query with return type A but A is an interface that has the B implementation. B is not directly declared in the Query class so it won't be added automatically),\nyou need to implement the `AdditionalGraphQLType` interface and add `@Component` annotation on top of the class.\n\n### Configurations\n\nAdd a properties file (using the graphql-spring-boot settings), for example `application.yml`:\n\n```yaml\nspring:\n  application:\n    name: graphql-todo-app\n  servlet:\n    multipart:\n      enabled: true\n      location: /tmp\nserver:\n  port: 8080\nmanagement:\n  endpoints:\n    web:\n      exposure:\n        include: health,info,metrics\ngraphql:\n  servlet:\n    tracing-enabled: false\n    actuator-metrics: false\n    contextSetting: PER_REQUEST_WITH_INSTRUMENTATION\naltair:\n  enabled: true\n  cdn:\n    enabled: false\ngraphiql:\n  enabled: true\n  cdn:\n    enabled: false\nvoyager:\n  enabled: false\n  cdn:\n    enabled: false\ngraphql.playground:\n  enabled: false\n  cdn:\n    enabled: false    \ndirectives.package: graphqla.directives\n```\n\nAnd you can go run your Application class.\nThat's it.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyarinvak%2Fgraphql-spring-annotations","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fyarinvak%2Fgraphql-spring-annotations","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyarinvak%2Fgraphql-spring-annotations/lists"}