Skip to main content

wgc grpc-service generate

The generate command generates a protobuf definition and mapping file for a gRPC service from a GraphQL schema, which can be used to implement a gRPC service and can be used for the composition. It supports two modes:
  1. Schema Mode: Generates a protobuf definition that mirrors the GraphQL schema. Used for implementing Subgraphs in gRPC (Connect Backend).
  2. Operations Mode: Generates a protobuf definition based on a set of GraphQL operations. Used for generating client SDKs (Connect Client).

Usage

Arguments

Options

Description

This command generates a protobuf definition for a gRPC service from a GraphQL schema.

Examples

Generate a protobuf definition for a gRPC service from a GraphQL schema (Schema Mode)

Generate a protobuf definition from operations (Operations Mode)

Define a custom package name

Define a custom go package name

Output

The command generates multiple files in the output directory:
  • service.proto: The protobuf definition for the gRPC service
  • service.mapping.json: The mapping file for the gRPC service (Schema Mode only)
  • service.proto.lock.json: The lock file for the protobuf definition
The generated protobuf definition can be used to implement a gRPC service in any language that supports protobuf, or to generate client SDKs. The mapping and the protobuf definition is needed for the composition part. See also: gRPC Services · GraphQL Support for gRPC Integration