Init - WunderGraph

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

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 go and ts is supported) go

Description

This command creates a new plugin directory with the specified name and scaffolds the basic plugin structure, including:

When --project is provided, a minimal router project is created in the project directory with:

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

Go

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

TypeScript

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
    ├── package.json
    ├── tsconfig.json
    ├── .gitignore
    ├── .cursorignore
    ├── .cursor/
    │   └── rules/
    │       └── plugin-development.mdc
    ├── src/
    │   ├── schema.graphql
    │   ├── plugin.ts
    │   ├── plugin-server.ts
    │   └── plugin.test.ts
    ├── generated/
    │   ├── mapping.json
    │   ├── service.proto
    │   └── service.proto.lock.json
    └── Dockerfile

Without --project

The plugin is created directly under the chosen directory:

Go

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

TypeScript

my-plugin/
├── README.md
├── Makefile
├── package.json
├── tsconfig.json
├── .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 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