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)
  • Language specific implementation files
    • For Go: src/main.go, src/main_test.go
    • For TS: src/plugin.ts, src/plugin.test.ts
  • Generated mapping and protocol files (generated/mapping.json, generated/service.proto, generated/service.proto.lock.json)
  • Language specific configuration (go.mod)
    • For Go: go.mod
    • For TS: package.json, tsconfig.json
  • 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

Without --project

The plugin is created directly under the chosen directory:

Examples

Basic usage

Create a new project and plugin

Specify a custom directory

Next Steps

Build Plugin

Test Plugin

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 or src/plugin.ts
  4. Implement your tests in src/main_test.go or src/plugin.test.ts and run them with make test
  5. Build your plugin with make build