Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix multiple schemas in config #193

Merged
merged 2 commits into from
Dec 31, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ func LoadConfig(filename string) (*Config, error) {
}

// https://github.com/99designs/gqlgen/blob/3a31a752df764738b1f6e99408df3b169d514784/codegen/config/config.go#L120
files := StringList{}
for _, f := range cfg.SchemaFilename {
var matches []string

Expand Down Expand Up @@ -168,16 +169,15 @@ func LoadConfig(filename string) (*Config, error) {
}
}

files := StringList{}
for _, m := range matches {
if !files.Has(m) {
files = append(files, m)
}
}

cfg.SchemaFilename = files
}

cfg.SchemaFilename = files

models := make(config.TypeMap)
if cfg.Models != nil {
models = cfg.Models
Comment on lines 169 to 183
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note: This review was outside the patches, so it was mapped to the patch with the greatest overlap. Original lines [140-176]

The logic for handling glob patterns and appending unique file paths to files appears correct. However, ensure that the StringList.Has method is efficient for larger sets of schema files, as it currently has O(n) complexity for each check.

// Consider using a map for efficient lookups if the number of schema files is large.

Expand Down
Loading