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

PR 239 update: Adding more logging for the initial generate setup #246

Merged
merged 2 commits into from
Dec 22, 2022
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
8 changes: 6 additions & 2 deletions generate/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,12 +102,16 @@ func (c *Config) ValidateAndFillDefaults(baseDir string) error {
if c.Package == "" {
abs, err := filepath.Abs(c.Generated)
if err != nil {
return errorf(nil, "unable to guess package-name: %v", err)
return errorf(nil, "unable to guess package-name: %v is not a valid identifier"+
"\nSet package name in genqlient.yaml"+
"\nExample: https://github.com/Khan/genqlient/blob/main/example/genqlient.yaml#L6", err)
}

base := filepath.Base(filepath.Dir(abs))
if !token.IsIdentifier(base) {
return errorf(nil, "unable to guess package-name: %v is not a valid identifier", base)
return errorf(nil, "unable to guess package-name: %v is not a valid identifier"+
"\nSet package name in genqlient.yaml"+
"\nExample: https://github.com/Khan/genqlient/blob/main/example/genqlient.yaml#L6", base)
}

c.Package = base
Expand Down
3 changes: 2 additions & 1 deletion generate/convert.go
Original file line number Diff line number Diff line change
Expand Up @@ -524,7 +524,8 @@ func (g *generator) convertDefinition(

// (If you had an entry in bindings, we would have returned it above.)
return nil, errorf(
pos, `unknown scalar %v: please add it to "bindings" in genqlient.yaml`, def.Name)
pos, "unknown scalar %v: please add it to \"bindings\" in genqlient.yaml"+
"\nExample: https://github.com/Khan/genqlient/blob/main/example/genqlient.yaml#L12", def.Name)
default:
return nil, errorf(pos, "unexpected kind: %v", def.Kind)
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
testdata/errors/UnknownScalar.schema.graphql:3: unknown scalar UnknownScalar: please add it to "bindings" in genqlient.yaml
Example: https://github.com/Khan/genqlient/blob/main/example/genqlient.yaml#L12
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
testdata/errors/UnknownScalar.schema.graphql:3: unknown scalar UnknownScalar: please add it to "bindings" in genqlient.yaml
Example: https://github.com/Khan/genqlient/blob/main/example/genqlient.yaml#L12