-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Deprecate gqlgen Binary #415
Comments
Can't agree enough. I hacked my way into this approach by copy/pasting internal code from gqlgen (see https://github.com/MichaelMure/git-bug/blob/master/graphql/gen_graphql.go), it works really well, no risk of version mismatch and go dep will vendor anything that might be required. That said, why the |
We want to make sure there are no breaking changes here, so once someone copies the stub in they should only need to change it again if they want to add a plugin. Secondly, we need to expose at least two commands, init and generate. Maybe we can package up init separately or get users to write a second entry point but it's additional work, and more surface area makes forward compatibility harder. We also thought about changing the root package, but it would be a breaking change for everyone currently using gqlgen. We should still make programmatic access to codegen a little cleaner, but we are focusing on improving the bootstrapping process which currently generates a few recurring issues (and probably causes some level of abandonment too) |
Worth mentioning that whatever the solution is, it should work for people who use 1.11's I personally always found the binary confusing, and much preferred just using |
I documented my (somewhat brute) approach to getting a working gqlbinary in issue #384 . No |
@emil-nasso nice job, that will get you across the line currently. The main issue you might eventually run into with your approach is that we may remove the #416 has a new getting started document that also works without |
@mathewbyrne migration seems to not work
|
@yakovzaytsev what does your
The docs could be a bit clearer on this. |
@mathewbyrne you are right. Thank you. BTW, if you link project root it does not work
then
|
Still does not work but I am not sure if that is relevant here @mathewbyrne mind quick look? I'm on macOS
|
@yakovzaytsev that doesn't look related to gqlgen specifically. Maybe something to do with your environment. The link thing is interesting. I would suggest link in reverse, and have the concrete folder in your |
Having finally upgraded to the latest gqlgen, I migrated to this solution. I'd like to suggest a slight improvement: Instead of using the func Generate(path string, verbose bool) error { /* ... */ }
func GenerateWithFilename(path string, verbose bool, filename string) error { /* ... */ } Usage would be something like: func main() {
cwd, _ := os.Getwd()
dir := path.Join(cwd, "graphql")
fmt.Println("Generating GraphQL code ...")
err := gqlgen.Generate(dir, false)
if err != nil {
log.Fatal(err)
}
} With the Advantages would be:
|
We though about doing that, but for bootstrapping (gqlgen init). We might also want additional subcommands. I don't see any harm in adding another function that can be used like this though, but it's probably not the default. |
Have only skimmed through this thread lightly (so take this with a grain of salt), but now that Go modules are here, doesn't that make the problems 1 and 2 in the original posting go away? For plugin support in 3, that would also mean that you limit gqlgen to running on Linux and macOS only, since other platforms (including Windows) are currently not supported. |
Correct, there is an update to this that wasn't referenced, but the #228 tracks plugin support. I suspect that we will require you to roll your own binary for custom plugins, and we'll do our best to make this as seamless as possible. |
Excellent! Thanks for the clarification. |
Currently we ship a binary with gqlgen, but increasingly we're running into several issues with it:
Bootstrapping is hard — we want to update the getting started docs to remove the
go get
usage, but then how do you run gqlgen in your project?Versioning differences — the getting started docs switch to using dep by their end, but this will cause issues if
master
is ahead of the latest release.Shipping Plugins — this becomes a lot harder since we need some way to load code dynamically from a fixed binary. We'd rather avoid trying to solve this by letting users roll their own binary anyway.
We're attempting to address the getting started issues at the moment with documentation, but we'd also like to make this code change at the same time. So starting from the next release out recommendation will be that you integrate gqlgen into your project by calling a new method in the
cmd
package. The documentation will be updated to reflect this.This approach isn't set in stone yet, and I'm open to any other suggestions people might have. We've already seen a few projects do something similar, calling into the
codegen
package to have a custom binary.Migration away
Follow these steps to migrate away from the gqlgen binary:
scripts/gqlgen.go
file with the following contents:dep
to manage dependencies for your project, ensure that you have them all now:Update any generate commands in your project to use this new script. Ensure that the path to the script is correct:
//go:generate go run scripts/gqlgen.go -v
(optional) Remove the previous binary from your bin path so that you aren't accidentally running a previous version of gqlgen.
The text was updated successfully, but these errors were encountered: