{"id":13433095,"url":"https://github.com/google/rejoiner","last_synced_at":"2025-10-02T08:30:49.368Z","repository":{"id":37926797,"uuid":"113356740","full_name":"google/rejoiner","owner":"google","description":"Generates a unified GraphQL schema from gRPC microservices and other Protobuf sources","archived":true,"fork":false,"pushed_at":"2023-06-13T22:58:03.000Z","size":793,"stargazers_count":3669,"open_issues_count":48,"forks_count":139,"subscribers_count":66,"default_branch":"master","last_synced_at":"2025-01-07T16:08:55.077Z","etag":null,"topics":["graphql","graphql-server","grpc","protobuf"],"latest_commit_sha":null,"homepage":"https://google.github.io/rejoiner/","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/google.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2017-12-06T19:09:53.000Z","updated_at":"2025-01-03T08:03:29.000Z","dependencies_parsed_at":"2022-07-15T21:48:36.780Z","dependency_job_id":"975aaf05-734a-4980-924d-65ac02658010","html_url":"https://github.com/google/rejoiner","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/google%2Frejoiner","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/google%2Frejoiner/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/google%2Frejoiner/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/google%2Frejoiner/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/google","download_url":"https://codeload.github.com/google/rejoiner/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":234957765,"owners_count":18913345,"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-server","grpc","protobuf"],"created_at":"2024-07-31T02:01:20.929Z","updated_at":"2025-10-02T08:30:43.936Z","avatar_url":"https://github.com/google.png","language":"Java","readme":"# Rejoiner\n\n[![Build Status](https://travis-ci.org/google/rejoiner.svg?branch=master)](https://travis-ci.org/google/rejoiner)\n[![Coverage Status](https://coveralls.io/repos/github/google/rejoiner/badge.svg?branch=master)](https://coveralls.io/github/google/rejoiner?branch=master)\n\u003c!-- [![Codacy Badge](https://api.codacy.com/project/badge/Grade/b43373716f2241a8bebd332e438b2454)](https://www.codacy.com/app/siderakis/rejoiner?utm_source=github.com\u0026amp;utm_medium=referral\u0026amp;utm_content=google/rejoiner\u0026amp;utm_campaign=Badge_Grade) --\u003e\n[![Maven Central](https://maven-badges.herokuapp.com/maven-central/com.google.api.graphql/rejoiner/badge.svg)](http://mvnrepository.com/artifact/com.google.api.graphql/rejoiner/0.0.4)\n\n\n - Creates a uniform GraphQL schema from microservices\n - Allows the GraphQL schema to be flexibly defined and composed as shared components\n - Generates GraphQL types from Proto definitions\n - Populates request Proto based on GraphQL query parameters\n - Supplies a DSL to modify the generated schema\n - Joins data sources by annotating methods that fetch data\n - Creates Proto [FieldMasks](https://developers.google.com/protocol-buffers/docs/reference/java/com/google/protobuf/FieldMask) based on GraphQL selectors\n\n ![Rejoiner Overview](./website/static/rejoiner_overview.svg)\n\n## Experimental Features\n\nThese features are actively being developed.\n\n - Expose any GraphQL schema as a gRPC service.\n - Lossless end to end proto scalar types when using gRPC.\n - Relay support [[Example](examples-gradle/src/main/java/com/google/api/graphql/examples/library)]\n - GraphQL Stream (based on gRPC streaming) [[Example](examples-gradle/src/main/java/com/google/api/graphql/examples/streaming)]\n\n## Schema Module\n\nSchemaModule is a Guice module that is used to generate parts of a GraphQL\nschema. It finds methods and fields that have Rejoiner annotations when it's\ninstantiated. It then looks at the parameters and return type of these methods\nin order to generate the appropriate GraphQL schema. Examples of queries,\nmutations, and schema modifications are presented below.\n\n## GraphQL Query\n\n```java\nfinal class TodoQuerySchemaModule extends SchemaModule {\n  @Query(\"listTodo\")\n  ListenableFuture\u003cListTodoResponse\u003e listTodo(ListTodoRequest request, TodoClient todoClient) {\n    return todoClient.listTodo(request);\n  }\n}\n```\n\nIn this example `request` is of type `ListTodoRequest` (a protobuf message), so\nit's used as a parameter in the generated GraphQL query. `todoService` isn't a\nprotobuf message, so it's provided by the Guice injector.\n\nThis is useful for providing rpc services or database access objects for\nfetching data. Authentication data can also be provided here.\n\nCommon implementations for these annotated methods:\n - Make gRPC calls to microservices which can be implemented in any language\n - Load protobuf messages directly from storage\n - Perform arbitrary logic to produce the result\n\n## GraphQL Mutation\n\n```java\nfinal class TodoMutationSchemaModule extends SchemaModule {\n  @Mutation(\"createTodo\")\n  ListenableFuture\u003cTodo\u003e createTodo(\n      CreateTodoRequest request, TodoService todoService, @AuthenticatedUser String email) {\n    return todoService.createTodo(request, email);\n  }\n}\n```\n\n## Adding edges between GraphQL types\n\nIn this example we are adding a reference to the User type on the Todo type.\n```java\nfinal class TodoToUserSchemaModule extends SchemaModule {\n  @SchemaModification(addField = \"creator\", onType = Todo.class)\n  ListenableFuture\u003cUser\u003e todoCreatorToUser(UserService userService, Todo todo) {\n    return userService.getUserByEmail(todo.getCreatorEmail());\n  }\n}\n```\nIn this case the Todo parameter is the parent object which can be referenced to\nget the creator's email.\n\nThis is how types are joined within and across APIs.\n\n![Rejoiner API Joining](./website/static/rejoiner.svg)\n\n## Removing a field\n\n```java\nfinal class TodoModificationsSchemaModule extends SchemaModule {\n  @SchemaModification\n  TypeModification removePrivateTodoData =\n      Type.find(Todo.getDescriptor()).removeField(\"privateTodoData\");\n}\n```\n\n## Building the GraphQL schema\n```java\nimport com.google.api.graphql.rejoiner.SchemaProviderModule;\n\npublic final class TodoModule extends AbstractModule {\n  @Override\n  protected void configure() {\n    // Guice module that provides the generated GraphQLSchema instance\n    install(new SchemaProviderModule());\n\n    // Install schema modules\n    install(new TodoQuerySchemaModule());\n    install(new TodoMutationSchemaModule());\n    install(new TodoModificationsSchemaModule());\n    install(new TodoToUserSchemaModule());\n  }\n}\n```\n\n## Getting started\n\n### Dependency information\n\nApache Maven\n```xml\n\u003cdependency\u003e\n    \u003cgroupId\u003ecom.google.api.graphql\u003c/groupId\u003e\n    \u003cartifactId\u003erejoiner\u003c/artifactId\u003e\n    \u003cversion\u003e0.0.4\u003c/version\u003e\n\u003c/dependency\u003e\n```\n\nGradle/Grails\n`compile 'com.google.api.graphql:rejoiner:0.0.4'`\n\nScala SBT\n`libraryDependencies += \"com.google.api.graphql\" % \"rejoiner\" % \"0.0.4\"`\n\n\n## Supported return types\n\nAll generated proto messages extend `Message`.\n - Any subclass of `Message`\n - `ImmutableList\u003c? extends Message\u003e`\n - `ListenableFuture\u003c? extends Message\u003e`\n - `ListenableFuture\u003cImmutableList\u003c? extends Message\u003e\u003e`\n\n## Project information\n\n - Rejoiner is built on top of [GraphQL-Java](https://github.com/graphql-java/graphql-java) which provides the core\n   GraphQL capabilities such as query parsing, validation, and execution.  \n - Java code is formatted using [google-java-format](https://github.com/google/google-java-format).\n - Note: This is not an official Google product.\n","funding_links":[],"categories":["Java","Java (78)","Language-Specific","Schema Libraries","Libraries"],"sub_categories":["Java","Code First","Java Libraries"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgoogle%2Frejoiner","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgoogle%2Frejoiner","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgoogle%2Frejoiner/lists"}