Skip to content

Commit

Permalink
Documenting support for Google APIs
Browse files Browse the repository at this point in the history
  • Loading branch information
siderakis committed Mar 26, 2018
1 parent 30e74d7 commit 2e2052e
Show file tree
Hide file tree
Showing 3 changed files with 64 additions and 0 deletions.
46 changes: 46 additions & 0 deletions docs/GOOGLE_APIS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
---
id: googleapis
title: Google APIs
---

Many of Google APIs are accessible using gRPC. The proto
definition of those APIs are [published on GitHub](https://github.com/googleapis/googleapis),
and can be used with Rejoiner to create a GraphQL gateway to Google APIs. This
gateway server can be hosted on the Google Could Platform allowing all
roundtrips to take place within the high-speed Google network.

Calls can be made using the standard Query annotation.

```
@Query("getDocument")
ListenableFuture<Document> getDocument(
GetDocumentRequest request, FirestoreClient client) {
return apiFutureToListenableFuture(client.getDocumentCallable().futureCall(request));
}
```

[Java clients](https://github.com/GoogleCloudPlatform/google-cloud-java) are
published for some of these APIs, which helps with authentication and other
concerns.

The `GaxSchemaModule` provides additional support to automatically generate
queries and mutations based on RPCs in these services.

```
@Namespace("firestore")
public final class FirestoreSchemaModule extends GaxSchemaModule {
@Override
protected void configureSchema() {
addQueryList(
serviceToFields(FirestoreClient.class, ImmutableList.of("getDocument", "listDocuments")));
addMutationList(
serviceToFields(
FirestoreClient.class,
ImmutableList.of("createDocument", "updateDocument", "deleteDocument")));
}
}
```


Additional fields can be added to types defined in these APIs.
17 changes: 17 additions & 0 deletions docs/QUERIES_AND_MUTATIONS.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,23 @@ final class TodoMutationSchemaModule extends SchemaModule {
}
```

## Nesting Queries and Mutations in a Namespace

Namespaces allow queries and mutations to be nested in logical groups. They
can help organize a large number of RPCs and can be useful for avoiding RPC name
collisions.

```java
@Namespace("todo")
final class TodoMutationSchemaModule extends SchemaModule {
@Mutation("createTodo")
ListenableFuture<Todo> createTodo(
CreateTodoRequest request, TodoService todoService, @AuthenticatedUser String email) {
return todoService.createTodo(request, email);
}
}
```

## Supported return types

All generated proto messages extend `Message`.
Expand Down
1 change: 1 addition & 0 deletions website/sidebars.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"examples"
],
"Advanced": [
"googleapis",
"relay",
"fieldmasks",
"implementation"
Expand Down

0 comments on commit 2e2052e

Please sign in to comment.