-
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
Generate server on running init #236
Conversation
codegen/templates/server.gotpl
Outdated
) | ||
|
||
func main() { | ||
port := flag.Int("p", 8080, "port number") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the PORT env var is commonly used for this (and removes the flag dep)
codegen/build.go
Outdated
imports := Imports{ | ||
destDir: destDir, | ||
} | ||
imports.add(cfg.Exec.ImportPath()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you probably should include any imports that aren't covered by https://github.com/vektah/gqlgen/blob/master/codegen/import_build.go#L11-L27 here too (http
and githhub.com/vektah/gqlgen/handler
)
Without them, gqlgen can end up with duplicate package aliases in the generated code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hrmm I didn't encounter that issue but sure. Updated.
2250ae1
to
121e8db
Compare
I am not getting a server on bare |
Init only works in an empty directory, maybe -v tells you more? |
Aha! It works in a non-empty directory, but it only creates the yaml. Got it. |
Generate server on running init
Update the
init
command to also generate a runnable server to help getting started even easier.