gRPC / Protobuf

This Handler allows you to load gRPC (opens in a new tab) definition files (.proto).
Terminal
yarn add @graphql-mesh/grpcNow, you can use it directly in your Mesh config file:
.meshrc.yaml
sources:
- name: MyGrpcApi
handler:
grpc:
endpoint: localhost:50051
source: grpc/proto/Example.proto💡
You can check out our example that uses gRPC Handler. Click here to open the example on GitHub (opens in a new tab)
Use Reflection instead of proto files
If you have configured reflection in your gRPC server, you don't need to provide source.
.meshrc.yaml
sources:
- name: gRPC Example
handler:
grpc:
endpoint: localhost:50051💡
You can check out our example that uses gRPC Handler with reflection. Click here to open the example on GitHub (opens in a new tab)
Custom Metadata for Authorization
Here you can use metaData field to pass some custom metadata from the context.
.meshrc.yaml
sources:
- name: MyGrpcApi
handler:
grpc:
endpoint: localhost:50051
source: grpc/proto/Example.proto
metaData:
authorization: 'Bearer {context.headers['x-my-token']}'
someStaticValue: 'MyStaticValue'Config API Reference
endpoint(type:String, required) - gRPC Endpointsource- - gRPC Proto file that contains your protobuf schema OR Use a binary-encoded or JSON file descriptor set file One of:object:file(type:String, required)load(type:Object):defaults(type:Boolean)includeDirs(type:Array of String)
String
requestTimeout(type:Int) - Request timeout in milliseconds Default: 200000credentialsSsl(type:Object) - SSL Credentials:rootCA(type:String)certChain(type:String)privateKey(type:String)
useHTTPS(type:Boolean) - Use https instead of http for gRPC connectionmetaData(type:JSON) - MetaDataprefixQueryMethod(type:Array of String) - prefix to collect Query method default: list, get