Skip to content

Commit

Permalink
Ability to use forceGenerate and extraFields together (#2788)
Browse files Browse the repository at this point in the history
* Ability to user forceGenerate and extraFields together

* Some docs for forceGenerate added

---------

Co-authored-by: Roman A. Grigorovich <ragrigorov@mts.ru>
  • Loading branch information
atzedus and Roman A. Grigorovich committed Sep 9, 2023
1 parent f90ac05 commit 9930e57
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
11 changes: 5 additions & 6 deletions codegen/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand All @@ -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)

Expand Down
6 changes: 6 additions & 0 deletions docs/content/config.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit 9930e57

Please sign in to comment.