From b738ff2f53f4d542fac043a3c8b868c3e486361a Mon Sep 17 00:00:00 2001 From: Sam Wallace <29391916+thecasual@users.noreply.github.com> Date: Sun, 20 Nov 2022 13:05:08 -0600 Subject: [PATCH 1/2] add a bit more logging --- generate/config.go | 8 ++++++-- generate/convert.go | 3 ++- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/generate/config.go b/generate/config.go index 7b98d2ac..6489440e 100644 --- a/generate/config.go +++ b/generate/config.go @@ -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 diff --git a/generate/convert.go b/generate/convert.go index 8073ae50..15281720 100644 --- a/generate/convert.go +++ b/generate/convert.go @@ -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) } From ce74737c07f1190552b3b42ecc44fbfd42448639 Mon Sep 17 00:00:00 2001 From: Steve Coffman Date: Tue, 20 Dec 2022 10:37:36 -0500 Subject: [PATCH 2/2] Update snapshots Signed-off-by: Steve Coffman --- generate/config.go | 8 ++++---- generate/convert.go | 2 +- .../snapshots/TestGenerateErrors-UnknownScalar-go | 1 + .../snapshots/TestGenerateErrors-UnknownScalar-graphql | 1 + 4 files changed, 7 insertions(+), 5 deletions(-) diff --git a/generate/config.go b/generate/config.go index 6489440e..3881c976 100644 --- a/generate/config.go +++ b/generate/config.go @@ -103,15 +103,15 @@ func (c *Config) ValidateAndFillDefaults(baseDir string) error { abs, err := filepath.Abs(c.Generated) if err != nil { 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) + "\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"+ - "\nSet package name in genqlient.yaml" + - "\nExample: https://github.com/Khan/genqlient/blob/main/example/genqlient.yaml#L6", base) + "\nSet package name in genqlient.yaml"+ + "\nExample: https://github.com/Khan/genqlient/blob/main/example/genqlient.yaml#L6", base) } c.Package = base diff --git a/generate/convert.go b/generate/convert.go index 15281720..caf3754f 100644 --- a/generate/convert.go +++ b/generate/convert.go @@ -525,7 +525,7 @@ 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"+ - "\nExample: https://github.com/Khan/genqlient/blob/main/example/genqlient.yaml#L12", def.Name) + "\nExample: https://github.com/Khan/genqlient/blob/main/example/genqlient.yaml#L12", def.Name) default: return nil, errorf(pos, "unexpected kind: %v", def.Kind) } diff --git a/generate/testdata/snapshots/TestGenerateErrors-UnknownScalar-go b/generate/testdata/snapshots/TestGenerateErrors-UnknownScalar-go index 3c698d27..ec3378e0 100644 --- a/generate/testdata/snapshots/TestGenerateErrors-UnknownScalar-go +++ b/generate/testdata/snapshots/TestGenerateErrors-UnknownScalar-go @@ -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 diff --git a/generate/testdata/snapshots/TestGenerateErrors-UnknownScalar-graphql b/generate/testdata/snapshots/TestGenerateErrors-UnknownScalar-graphql index 3c698d27..ec3378e0 100644 --- a/generate/testdata/snapshots/TestGenerateErrors-UnknownScalar-graphql +++ b/generate/testdata/snapshots/TestGenerateErrors-UnknownScalar-graphql @@ -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