Skip to content

Commit

Permalink
Add mention of tools.go to FAQ (Khan#189)
Browse files Browse the repository at this point in the history
This came up in Khan#160, and will surely come up again. I hope the Go
folks figure out something better here, but until such time...
  • Loading branch information
benjaminjkraft authored Apr 29, 2022
1 parent 39a980a commit c8cbe80
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion docs/FAQ.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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"
```

0 comments on commit c8cbe80

Please sign in to comment.