Skip to content
This repository was archived by the owner on Apr 1, 2024. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
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: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,12 @@ If you want to specify multiple schema, you can use `--schema` flag repeatedly.
$ gqldoc -s a.graphql -s b.graphql -o ./doc_dir
```

You can also use glob.

```sh
$ gqldoc -s "schema/**/*.graphql" -o ./doc_dir
```

## Installation

### Mac and Linux users via Homebrew
Expand Down
19 changes: 14 additions & 5 deletions cmd/gqldoc/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (
"github.com/Code-Hex/gqldoc/loader"
"github.com/machinebox/graphql"
gqlcli "github.com/machinebox/graphql"
"github.com/mattn/go-zglob"
"github.com/pkg/errors"
"github.com/urfave/cli/v2"
)
Expand Down Expand Up @@ -122,15 +123,23 @@ func convertSchemaTree(schemaFiles []string) (*introspection.Root, error) {
return nil, errHelp
}

gqlfiles := make([]string, 0, len(schemaFiles))
for _, schema := range schemaFiles {
switch filepath.Ext(schema) {
case ".graphqls", ".graphql", ".gql":
default:
return nil, errHelp
matches, err := zglob.Glob(schema)
if err != nil {
return nil, errors.WithStack(err)
}
for _, maybeSchema := range matches {
switch filepath.Ext(maybeSchema) {
case ".graphqls", ".graphql", ".gql":
gqlfiles = append(gqlfiles, maybeSchema)
default:
return nil, errHelp
}
}
}

schema, err := loader.LoadSchema(schemaFiles...)
schema, err := loader.LoadSchema(gqlfiles...)
if err != nil {
return nil, errors.WithStack(err)
}
Expand Down
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ require (
github.com/99designs/gqlgen v0.13.0
github.com/machinebox/graphql v0.2.2
github.com/matryer/is v1.4.0 // indirect
github.com/mattn/go-zglob v0.0.3
github.com/pkg/errors v0.8.1
github.com/russross/blackfriday/v2 v2.1.0
github.com/urfave/cli/v2 v2.3.0
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ github.com/matryer/moq v0.0.0-20200106131100-75d0ddfc0007/go.mod h1:9ELz6aaclSIG
github.com/mattn/go-colorable v0.1.4/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVcfRqFIhoBtE=
github.com/mattn/go-isatty v0.0.8/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s=
github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU=
github.com/mattn/go-zglob v0.0.3 h1:6Ry4EYsScDyt5di4OI6xw1bYhOqfE5S33Z1OPy+d+To=
github.com/mattn/go-zglob v0.0.3/go.mod h1:9fxibJccNxU2cnpIKLRRFA7zX7qhkJIQWBb449FYHOo=
github.com/mitchellh/mapstructure v0.0.0-20180203102830-a4e142e9c047/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y=
github.com/opentracing/basictracer-go v1.0.0/go.mod h1:QfBfYuafItcjQuMwinw9GhYKwFXS9KnPs5lxoYwgW74=
github.com/opentracing/opentracing-go v1.0.2/go.mod h1:UkNAQd3GIcIGf0SeVgPpRdFStlNbqXla1AfSYxPUl2o=
Expand Down