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> | The name of the project | cosmo |
-d, --directory <directory> | Directory to create the plugin in | . (current directory) |
-l, --language <language> | Programming language to use for the plugin | go |
--only-plugin | Creates only a plugin without bootstrapping a full router project | false |
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)
Directory Structure
After initialization, your project directory will have the following structure:generated/: Contains generated Go code based on your schemabin/: Contains compiled binaries for your plugin
--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:- Customize the GraphQL schema in
src/schema.graphql - Generate the Go code with
make 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