From c8cbe805eb72aeb6d5e13b9a58c827b4d1f44a6e Mon Sep 17 00:00:00 2001 From: Ben Kraft Date: Fri, 29 Apr 2022 13:26:32 -0700 Subject: [PATCH] Add mention of tools.go to FAQ (#189) This came up in #160, and will surely come up again. I hope the Go folks figure out something better here, but until such time... --- docs/FAQ.md | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/docs/FAQ.md b/docs/FAQ.md index 4793b4f..35b084c 100644 --- a/docs/FAQ.md +++ b/docs/FAQ.md @@ -8,7 +8,7 @@ This document describes common questions about genqlient, and provides an index There's a [doc for that](INTRODUCTION.md)! -## … use GET requests instead of POST requests? +### … use GET requests instead of POST requests? You can use `graphql.NewClientUsingGet` to create a client that will use query parameters to create the request. For example: ```go @@ -549,3 +549,16 @@ genqlient will instead generate types with the given names. (You'll need to avo ### … my editor/IDE plugin not know about the code genqlient just generated? If your tools are backed by [gopls](https://github.com/golang/tools/blob/master/gopls/README.md) (which is most of them), they simply don't know it was updated. In most cases, keeping the generated file (typically `generated.go`) open in the background, and reloading it after each run of `genqlient`, will do the trick. + +### … genqlient fail after `go mod tidy`? + +If genqlient fails with an error `missing go.sum entry for module providing package`, this is typically because `go mod tidy` removed its dependencies because they weren't imported by your Go module. You can read more about this in golang/go#45552; see in particular [this comment](https://github.com/golang/go/issues/45552#issuecomment-819545037). In short, if you want to be able to `go run` on newer Go you'll need to have a (blank) import of genqlient's entrypoint in a special `tools.go` file somewhere in your module so `go mod tidy` doesn't prune it: + +```go +//go:build tools +// +build tools + +package client + +import _ "github.com/Khan/genqlient" +```