Examples
Helloworld HTTP Server
This example showcases generating a GraphQL schema from a simple gRPC service. The GraphQL server makes rpc calls to the backend server.
To run the example you need to run the backend gRPC server first, then run the GraphQL frontend server.
Build and run the gRPC backend server
From the top level directory run these commands:
> cd examples > ./gradlew installDist > ./build/install/examples/bin/helloworld-backend
Run the GraphQL frontend server
In another terminal run the following command:
> ./build/install/examples/bin/helloworld-graphqlserver
Visit GraphiQL and make requests
Streaming GraphQL using gRPC
This example showcases a streaming GraphQL response. The goal is to support the @streaming
directive.
Note: This is a work in progress
Run the gRPc backend server
> cd examples > ./gradlew installDist > ./build/install/examples/bin/streaming-backend
Run the GraphQL frontend gRPC server
> cd examples > ./build/install/examples/bin/streaming-graphql-server
Run the GraphQL gRPC client
> cd examples > ./build/install/examples/bin/streaming-graphql-client
Current Limitations of Streaming Demo
- The response is always streaming (it doesn't depend on the presents of the @streaming directive)
- The demo is using a gRPC service for the GraphQL API (no HTTP/JSON demo).
- The data field of the top level GraphQL Response proto is a JSON encoded string of the response (it could be either Any or oneOf())
- Variables are not used in the demo
- Errors are not returned in the response
Library Example
The library example uses DataLoaders which provides a request-scoped cache and automatically batches requests.
Community Examples
github.com/dbaggett/medallion contains multiple microservices and uses Kotlin instead of Java.