-
Notifications
You must be signed in to change notification settings - Fork 114
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
⚡️ Accept array of string as valid input schema path. (#134)
* ⚡️ Fixes #88. Accept array of string as valid input schema path.
- Loading branch information
Hasibul Hasan
authored
Oct 4, 2021
1 parent
5e3c4d1
commit 59b6df6
Showing
7 changed files
with
124 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package generate | ||
|
||
// StringList provides yaml unmarshaler to accept both `string` and `[]string` as a valid type. | ||
// Sourced from: | ||
// https://github.com/99designs/gqlgen/blob/1a0b19feff6f02d2af6631c9d847bc243f8ede39/codegen/config/config.go#L302-L329 | ||
type StringList []string | ||
|
||
func (a *StringList) UnmarshalYAML(unmarshal func(interface{}) error) error { | ||
var single string | ||
err := unmarshal(&single) | ||
if err == nil { | ||
*a = []string{single} | ||
return nil | ||
} | ||
|
||
var multi []string | ||
err = unmarshal(&multi) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
*a = multi | ||
return nil | ||
} | ||
|
||
func (a StringList) Has(file string) bool { | ||
for _, existing := range a { | ||
if existing == file { | ||
return true | ||
} | ||
} | ||
return false | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters