wgc router plugin generate
Thegenerate
command creates Protocol Buffers definitions, mapping files, and gRPC code based on your GraphQL schema. This command is useful when you want to generate the necessary code without compiling binaries.
Usage
Arguments
Argument | Description | Default |
---|---|---|
directory | Directory of the plugin | . (current directory) |
Options
Option | Description | Default |
---|---|---|
--go-module-path <path> | Go module path to use for the plugin | github.com/wundergraph/cosmo/plugin |
--skip-tools-installation | Skip tool installation | false |
--force-tools-installation | Force tools installation regardless of version check or confirmation | false |
Description
This command performs the code generation steps of the plugin build process:- Generate Proto and Mapping Files: Processes your GraphQL schema to generate Protocol Buffers definitions and mapping files
- Generate gRPC Code: Uses the generated Proto files to create Go code for the gRPC service
- Install Go Dependencies: Installs all required Go dependencies for your plugin
generate
command is equivalent to running build
with the --generate-only
flag. Use this when you’re iterating on your GraphQL schema and need to regenerate the code without compiling binaries.
Required Tools
The generate command will automatically check for and install the necessary toolchain when required tools can’t be found in the right version on your system. You can control this behavior with the--skip-tools-installation
and --force-tools-installation
flags.
You can also install the dependencies manually and use an IDE with Go support. The following table shows the current versions and download links for the required tools:
Tool | Version | Installation Link |
---|---|---|
Go | >=1.22.0 (Last 2 versions) | Releases |
Protocol Buffers (protoc) | ^29.3 | Releases |
protoc-gen-go | ^1.34.2 | GitHub Releases |
protoc-gen-go-grpc | ^1.5.1 | GitHub Releases |
Examples
Generate code for the current directory
Generate code for a specific plugin directory
Generate with a custom Go module path
Skip tool installation (useful in CI environments)
Output
The generate process creates the following outputs:- Proto files: Protocol Buffers definitions in the
generated/
directory - Mapping files: Schema mapping files that connect your GraphQL schema to the gRPC service
- Generated Go code: gRPC client and server code in the
generated/
directory - Go dependencies: All required dependencies will be installed in your Go module
build
to compile the plugin into binaries.