wgc router plugin init

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

Usage

wgc router plugin init [options] <name>

Arguments

ArgumentDescription
nameName of the plugin

Options

OptionDescriptionDefault
-p, --project <project>Project name. When provided, a minimal router project is bootstrapped and the plugin is created at <project>/<name>.(none)
-d, --directory <directory>Directory to create the plugin or project in. (current directory)
-l, --language <language>Programming language to use for the plugin (currently only go is supported)go

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 mapping and protocol files (generated/mapping.json, generated/service.proto, generated/service.proto.lock.json)
  • Go module configuration (go.mod)
  • Makefile and Dockerfile (Makefile, Dockerfile)
  • Documentation (README.md)
When --project is provided, a minimal router project is created in the project directory with:
  • Router configuration files in the project root (config.yaml, graph.yaml)
  • Project-level files (README.md, Makefile, .gitignore)
  • The plugin located at <project>/<name>
If you want to create a plugin in an existing project directory, omit --project and use -d/--directory to choose where the plugin directory should be created.

Directory Structure

With --project

my-project/
├── README.md                 # Project documentation
├── Makefile                  # Project Makefile
├── config.yaml               # Router configuration
├── graph.yaml                # Supergraph configuration
├── .gitignore
└── my-plugin/                # Your plugin directory
    ├── README.md
    ├── Makefile
    ├── go.mod
    ├── .gitignore
    ├── .cursorignore
    ├── .cursor/
    │   └── rules/
    │       └── plugin-development.mdc
    ├── src/
    │   ├── schema.graphql
    │   ├── main.go
    │   └── main_test.go
    ├── generated/
    │   ├── mapping.json
    │   ├── service.proto
    │   └── service.proto.lock.json
    └── Dockerfile

Without --project

The plugin is created directly under the chosen directory:

my-plugin/
├── README.md
├── Makefile
├── go.mod
├── .gitignore
├── .cursorignore
├── .cursor/
│   └── rules/
│       └── plugin-development.mdc
├── src/
│   ├── schema.graphql
│   ├── main.go
│   └── main_test.go
├── generated/
│   ├── mapping.json
│   ├── service.proto
│   └── service.proto.lock.json
└── Dockerfile

Examples

Basic usage

wgc router plugin init users

Create a new project and plugin

wgc router plugin init users -p cosmo

Specify a custom directory

wgc router plugin init users -d ./plugins

Next Steps

After initializing your plugin, you should:
  1. Customize the GraphQL schema in src/schema.graphql
  2. Generate code with wgc router plugin generate or 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