Skip to content

Commit

Permalink
fix: automatically register built-in directive goTag (#1737)
Browse files Browse the repository at this point in the history
* fix: automatically register built-in tag goTag

* doc: add directive config documentation
  • Loading branch information
tprebs authored Dec 3, 2021
1 parent 497227f commit bd8938d
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
4 changes: 4 additions & 0 deletions codegen/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,10 @@ func (c *Config) injectTypesFromSchema() error {
SkipRuntime: true,
}

c.Directives["goTag"] = DirectiveConfig{
SkipRuntime: true,
}

for _, schemaType := range c.Schema.Types {
if schemaType == c.Schema.Query || schemaType == c.Schema.Mutation || schemaType == c.Schema.Subscription {
continue
Expand Down
13 changes: 13 additions & 0 deletions docs/content/config.md
Original file line number Diff line number Diff line change
Expand Up @@ -115,3 +115,16 @@ type User @goModel(model: "github.com/my/app/models.User") {
@goTag(key: "yaml")
}
```

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.

If you have created a new code generation plugin using a directive which does not require runtime execution, the directive will need to be set to `skip_runtime`.

e.g. a custom directive called `constraint` would be set as `skip_runtime` using the following configuration
```yml
# custom directives which are not exposed during introspection. These directives are
# used for code generation only
directives:
constraint:
skip_runtime: true
```

0 comments on commit bd8938d

Please sign in to comment.