wgc router plugin init
Theinit command scaffolds a new gRPC router plugin project with all the necessary files and directory structure.
Usage
Arguments
| Argument | Description | 
|---|---|
| name | Name of the plugin | 
Options
| Option | Description | Default | 
|---|---|---|
| -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 gois 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)
--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>
--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
After initializing your plugin, you should:- Customize the GraphQL schema in src/schema.graphql
- Generate code with wgc router plugin generateormake generate
- Implement your resolvers in src/main.go
- Implement your tests in src/main_test.goand run them withmake test
- Build your plugin with make build