Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

POC: Use gRPC instead of HTTP to communicate to services #1

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

dounan
Copy link
Owner

@dounan dounan commented Jan 13, 2020

Description

Implement and use our own GrpcGraphQLDataSource instead of relying on apollo-gateway's default HTTP data source.

Manual Testing

To test it out, follow the instructions here: https://github.com/Gusto/apollo-federation-ruby#example

Open up the graphql playground after starting the gateway by visiting http://localhost:50000/graphql

Future

Apollo has plans in the future to make their server less reliant on HTTP, which will make this even easier (since right now we have to pull out and ignore the http field of the request).

if (config.type === 'grpc') {
return new GrpcGraphQLDataSource(config);
}
return new RemoteGraphQLDataSource(config);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

are we trying to handle both grpc and http case now?

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I left it in there during my experimentation. I don't see any harm in allowing both in case some service really wants to expose an HTTP /graphql endpoint, but we will encourage the use gRPC

require 'json'
require_relative './gen/federation_api_pb'
require_relative './gen/federation_api_services_pb'

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's call this file graphql_grpc_server

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is just a proof of concept 😉

@JuanyiFeng
Copy link

This approach LGTM, can you run it with the frontend infra team?

@dounan
Copy link
Owner Author

dounan commented Jan 13, 2020

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants