22019287da
Multiple schema-files are now supported as of #134, but the support was a bit different from how we did multiple operation-files. Before anyone starts to depend on the ways the syntaxes differ, let's just make them the same. Since it's easy, I also added support for having just a single operations-file. I also realized while writing this that the type-change is technically breaking (if you call from Go), so documented it as such. I think this is unlikely to affect many people. Test plan: make check
25 lines
565 B
Go
25 lines
565 B
Go
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
|
|
}
|