Repository: Khan/genqlient
Pull request #208 (2022-06-16 21:16:47)

Release v0.5.0
It feels like just yesterday, but it's been over four months since our
last release! So it's as good a time as any; while there are quite a few
changes they're individually mostly small. As usual, this updates the
changelog, and I'll tag it with the release once it lands. I also bumped
our gqlparser version, and removed a workaround we had for a bug
upstream that is now fixed.

Test plan: no relevant bug reports lately

<!--
Thanks for your contribution! Check out the
[contributing docs](https://github.com/Khan/genqlient/blob/main/docs/CONTRIBUTING.md)
for more on contributing to genqlient.
-->



I have:
- [x] Written a clear PR title and description (above)
- [x] Signed the [Khan Academy CLA](https://www.khanacademy.org/r/cla)
- [x] Added tests covering my changes, if applicable
- [x] Included a link to the issue fixed, if applicable
- [x] Included documentation, for new features
- [x] Added an entry to the changelog


StevenACoffman: Hey, did you want to first  update [vektah/gqlparser](github.com/vektah/gqlparser) to v2.4.5 to include your upstream fix there into genqlient before you release v0.5.0? 
benjaminjkraft: Ah, good idea, may as well.

Patch:
diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md
index 692d7dd..1598619 100644
--- a/docs/CHANGELOG.md
+++ b/docs/CHANGELOG.md
@@ -22,6 +22,16 @@ When releasing a new version:
 
 ### Breaking changes:
 
+### New features:
+
+### Bug fixes:
+
+## v0.5.0
+
+Version 0.5.0 adds several new configuration options and convenience features. Note that genqlient now requires Go 1.16 or higher, and is tested through Go 1.18.
+
+### Breaking changes:
+
 - genqlient now requires Go 1.16 or higher.
 - The [`graphql.Client`](https://pkg.go.dev/github.com/Khan/genqlient/graphql#Client) interface now accepts two structs for the request and response, to allow future expansion, rather than several individual arguments.  Clients implementing the interface themselves will need to change the signature; clients who simply call `graphql.NewClient` are unaffected.
 
diff --git a/generate/generate.go b/generate/generate.go
index 6af6cf1..cb5acf4 100644
--- a/generate/generate.go
+++ b/generate/generate.go
@@ -228,17 +228,10 @@ func (g *generator) preprocessQueryDocument(doc *ast.QueryDocument) {
 // considers valid but we don't allow, and returns an error if this operation
 // is invalid for genqlient's purposes.
 func (g *generator) validateOperation(op *ast.OperationDefinition) error {
-	opType, err := g.baseTypeForOperation(op.Operation)
-	switch {
-	case err != nil:
+	_, err := g.baseTypeForOperation(op.Operation)
+	if err != nil {
 		// (e.g. operation has subscriptions, which we don't support)
 		return err
-	case opType == nil:
-		// gqlparser should err here, but doesn't [1], so we err to prevent
-		// panics later.
-		// TODO(benkraft): Remove once gqlparser is fixed.
-		// [1] https://github.com/vektah/gqlparser/issues/221
-		return errorf(op.Position, "schema has no %v type", op.Operation)
 	}
 
 	if op.Name == "" {
diff --git a/go.mod b/go.mod
index 14462c8..1531ea4 100644
--- a/go.mod
+++ b/go.mod
@@ -8,7 +8,7 @@ require (
 	github.com/alexflint/go-arg v1.4.2
 	github.com/bradleyjkemp/cupaloy/v2 v2.6.0
 	github.com/stretchr/testify v1.7.0
-	github.com/vektah/gqlparser/v2 v2.4.1
+	github.com/vektah/gqlparser/v2 v2.4.5
 	golang.org/x/sys v0.0.0-20220319134239-a9b59b0215f8 // indirect
 	golang.org/x/tools v0.1.10
 	gopkg.in/yaml.v2 v2.4.0
diff --git a/go.sum b/go.sum
index 6676044..e519639 100644
--- a/go.sum
+++ b/go.sum
@@ -55,8 +55,8 @@ github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5Cc
 github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
 github.com/urfave/cli/v2 v2.3.0/go.mod h1:LJmUH05zAU44vOAcrfzZQKsZbVcdbOG8rtL3/XcUArI=
 github.com/vektah/gqlparser/v2 v2.4.0/go.mod h1:flJWIR04IMQPGz+BXLrORkrARBxv/rtyIAFvd/MceW0=
-github.com/vektah/gqlparser/v2 v2.4.1 h1:QOyEn8DAPMUMARGMeshKDkDgNmVoEaEGiDB0uWxcSlQ=
-github.com/vektah/gqlparser/v2 v2.4.1/go.mod h1:flJWIR04IMQPGz+BXLrORkrARBxv/rtyIAFvd/MceW0=
+github.com/vektah/gqlparser/v2 v2.4.5 h1:C02NsyEsL4TXJB7ndonqTfuQOL4XPIu0aAWugdmTgmc=
+github.com/vektah/gqlparser/v2 v2.4.5/go.mod h1:flJWIR04IMQPGz+BXLrORkrARBxv/rtyIAFvd/MceW0=
 github.com/yuin/goldmark v1.1.32/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
 github.com/yuin/goldmark v1.4.1/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k=
 golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=


Test patch:
diff --git a/generate/testdata/snapshots/TestGenerateErrors-NoMutationType-graphql b/generate/testdata/snapshots/TestGenerateErrors-NoMutationType-graphql
index 2c40a67..573149a 100644
--- a/generate/testdata/snapshots/TestGenerateErrors-NoMutationType-graphql
+++ b/generate/testdata/snapshots/TestGenerateErrors-NoMutationType-graphql
@@ -1,1 +1,1 @@
-testdata/errors/NoMutationType.graphql:1: schema has no mutation type
+testdata/errors/NoMutationType.graphql:1: query-spec does not match schema: Schema does not support operation type "mutation"
diff --git a/generate/testdata/snapshots/TestGenerateErrors-NoQueryType-graphql b/generate/testdata/snapshots/TestGenerateErrors-NoQueryType-graphql
index aa00a56..779db1b 100644
--- a/generate/testdata/snapshots/TestGenerateErrors-NoQueryType-graphql
+++ b/generate/testdata/snapshots/TestGenerateErrors-NoQueryType-graphql
@@ -1,1 +1,1 @@
-testdata/errors/NoQueryType.graphql:1: schema has no query type
+testdata/errors/NoQueryType.graphql:1: query-spec does not match schema: Schema does not support operation type "query"