From 96236201ce9f9d104df369331dddd0b31b4a431d Mon Sep 17 00:00:00 2001 From: "Roman A. Grigorovich" Date: Sat, 9 Sep 2023 01:59:46 +0300 Subject: [PATCH 1/2] Ability to user forceGenerate and extraFields together --- codegen/config/config.go | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) 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) From c8847f0f39da7a09b53c5446b6a25d60279412b7 Mon Sep 17 00:00:00 2001 From: "Roman A. Grigorovich" Date: Sat, 9 Sep 2023 02:14:55 +0300 Subject: [PATCH 2/2] Some docs for forceGenerate added --- docs/content/config.md | 6 ++++++ 1 file changed, 6 insertions(+) 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.