v0.9.3
v0.9.3 v0.17.3 v0.17.2 v0.17.1 v0.17.0 v0.16.0 v0.15.1 v0.15.0 v0.14.0 v0.13.0 v0.12.2 v0.12.1 v0.12.0 v0.11.3 v0.11.2 v0.11.1 v0.11.0 v0.10.2 v0.10.1 v0.10.0 master

Plugins

How to write plugins for gqlgen
[edit]
You are looking at the docs for an older version (v0.9.3). The latest version is v0.17.3.

Plugins provide a way to hook into the gqlgen code generation lifecycle. In order to use anything other than the default plugins you will need to create your own entrypoint:

Using a plugin

// +build ignore

package main

import (
	"flag"
	"fmt"
	"io/ioutil"
	"log"
	"os"
	"time"

	"github.com/99designs/gqlgen/api"
	"github.com/99designs/gqlgen/codegen/config"
	"github.com/99designs/gqlgen/plugin/stubgen"
)

func main() {
	cfg, err := config.LoadConfigFromDefaultLocations()
	if err != nil {
		fmt.Fprintln(os.Stderr, "failed to load config", err.Error())
		os.Exit(2)
	}


	err = api.Generate(cfg, 
		api.AddPlugin(yourplugin.New()), // This is the magic line
	)
	if err != nil {
		fmt.Fprintln(os.Stderr, err.Error())
		os.Exit(3)
	}
}

Writing a plugin

There are currently only two hooks:

Take a look at plugin.go for the full list of available hooks. These are likely to change with each release.