Skip to main content

wgc router plugin init

The init command scaffolds a new gRPC router plugin project with all the necessary files and directory structure.

Usage

Arguments

Options

Description

This command creates a new plugin directory with the specified name and scaffolds the basic plugin structure, including:
  • A GraphQL schema file (src/schema.graphql)
  • Go implementation files (src/main.go, src/main_test.go)
  • Generated protocol files (generated/service.proto)
  • Go module configuration (go.mod)
  • Documentation (README.md)
The scaffolded plugin includes a hello world example that you can customize according to your needs.

Directory Structure

After initialization, your project directory will have the following structure:
During later build steps, additional files will be generated:
  • generated/: Contains generated Go code based on your schema
  • bin/: Contains compiled binaries for your plugin
You can also generate only the plugin without bootstrapping a full router project by using the --only-plugin flag. This is useful if you want to create a plugin in an existing router project.

Examples

Basic usage

Specify a custom directory

Next Steps

After initializing your plugin, you should:
  1. Customize the GraphQL schema in src/schema.graphql
  2. Generate the Go code with make generate
  3. Implement your resolvers in src/main.go
  4. Implement your tests in src/main_test.go and run them with make test
  5. Build your plugin with make build
For more information on these steps, see the build and test command documentation.