diff --git a/codegen/config/config.go b/codegen/config/config.go index ddf10ac21d3..1e844f4696d 100644 --- a/codegen/config/config.go +++ b/codegen/config/config.go @@ -600,12 +600,7 @@ func (c *Config) autobind() error { ps := c.Packages.LoadAll(c.AutoBind...) for _, t := range c.Schema.Types { - if c.Models.UserDefined(t.Name) { - continue - } - - if c.Models[t.Name].ForceGenerate { - delete(c.Models, t.Name) + if c.Models.UserDefined(t.Name) || c.Models[t.Name].ForceGenerate { continue } @@ -621,6 +616,10 @@ func (c *Config) autobind() error { } for i, t := range c.Models { + if t.ForceGenerate { + continue + } + for j, m := range t.Model { pkg, typename := code.PkgAndType(m) diff --git a/docs/content/config.md b/docs/content/config.md index 26dba6fed83..f464359aca8 100644 --- a/docs/content/config.md +++ b/docs/content/config.md @@ -165,6 +165,12 @@ type User @goModel(model: "github.com/my/app/models.User") { @goTag(key: "xorm", value: "-") @goTag(key: "yaml") } + +# This make sense when autobind activated. +type Person @goModel(forceGenerate: true) { + id: ID! + name: String! +} ``` The builtin directives `goField`, `goModel` and `goTag` are automatically registered to `skip_runtime`. Any directives registered as `skip_runtime` will not exposed during introspection and are used during code generation only.