Skip to content

Commit

Permalink
Add a config option to skip running "go mod tidy" on code generation (#…
Browse files Browse the repository at this point in the history
…1644)

Co-authored-by: Hooman Yar <hooman.yar@coinbase.com>
  • Loading branch information
0xhmn and Hooman Yar authored Oct 14, 2021
1 parent 658195b commit 8b25c9e
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
7 changes: 5 additions & 2 deletions api/generate.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,11 @@ func Generate(cfg *config.Config, option ...Option) error {
if err = codegen.GenerateCode(data); err != nil {
return fmt.Errorf("generating core failed: %w", err)
}
if err = cfg.Packages.ModTidy(); err != nil {
return fmt.Errorf("tidy failed: %w", err)

if !cfg.SkipModTidy {
if err = cfg.Packages.ModTidy(); err != nil {
return fmt.Errorf("tidy failed: %w", err)
}
}

for _, p := range plugins {
Expand Down
1 change: 1 addition & 0 deletions codegen/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ type Config struct {
Directives map[string]DirectiveConfig `yaml:"directives,omitempty"`
OmitSliceElementPointers bool `yaml:"omit_slice_element_pointers,omitempty"`
SkipValidation bool `yaml:"skip_validation,omitempty"`
SkipModTidy bool `yaml:"skip_mod_tidy,omitempty"`
Sources []*ast.Source `yaml:"-"`
Packages *code.Packages `yaml:"-"`
Schema *ast.Schema `yaml:"-"`
Expand Down
3 changes: 3 additions & 0 deletions docs/content/config.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ resolver:
# Optional: set to speed up generation time by not performing a final validation pass.
# skip_validation: true

# Optional: set to skip running `go mod tidy` when generating server code
# skip_mod_tidy: true

# gqlgen will search for any type names in the schema in these go packages
# if they match it will use them, otherwise it will generate them.
autobind:
Expand Down

0 comments on commit 8b25c9e

Please sign in to comment.