⚠️
This is the documentation for the old GraphQL Mesh version v0. We recommend upgrading to the latest GraphQL Mesh version v1.
Migrate to GraphQL Mesh v1
Migrate to GraphQL Mesh v1
gRPC / Protobuf

This Handler allows you to load gRPC definition files (.proto).
npm i @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
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
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'Reflection Metadata (reflectionMetadata)
When using gRPC reflection (no source), use reflectionMetadata to send metadata only on
reflection requests — for example routing headers required by your infrastructure:
.meshrc.yaml
sources:
- name: MyGrpcApi
handler:
grpc:
endpoint: localhost:50051
reflectionMetadata:
grpc-service: proto.MyGrpcService
authorization: 'Bearer {env.REFLECTION_TOKEN}'Channel Options & Timeouts
requestTimeoutsets a per-call deadline (milliseconds from the start of each request).channelOptionsare passed to the gRPC client constructor (message size limits, keepalive, etc.):
.meshrc.yaml
sources:
- name: MyGrpcApi
handler:
grpc:
endpoint: localhost:50051
requestTimeout: 5000
channelOptions:
grpc.max_receive_message_length: 10000000
grpc.keepalive_time_ms: 10000
grpc.keepalive_timeout_ms: 5000
grpc.keepalive_permit_without_calls: 1Config 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, getselectQueryOrMutationField(type:Array of Object) - Allows to explicitly override the default operation (Query or Mutation) for any gRPC operation:type(type:String (query | mutation | Query | Mutation), required)fieldName(type:String, required)
schemaHeaders(type:JSON) - HTTP headers whensourcepoints to a remote.graphqlSDLreflectionMetadata(type:JSON) - gRPC metadata sent with server-reflection requests (e.g. routing / auth metadata). Only used when loading the schema via reflection (nosource/ emptysource).channelOptions(type:JSON) - Channel options passed to the gRPC client (e.g. grpc.max_receive_message_length, grpc.keepalive_time_ms). See https://grpc.github.io/grpc/core/group__grpc__arg__keys.html
Last updated on