Skip to content
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

Merged
merged 1 commit into from
Aug 1, 2018
Merged

Conversation

creativej
Copy link
Member

Update the init command to also generate a runnable server to help getting started even easier.

@creativej creativej requested a review from vektah July 31, 2018 07:52
)

func main() {
port := flag.Int("p", 8080, "port number")
Copy link
Collaborator

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())
Copy link
Collaborator

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.

Copy link
Member Author

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.

@creativej creativej merged commit 17bcb32 into next Aug 1, 2018
@creativej creativej deleted the generate-handler-on-init branch August 1, 2018 00:52
@ermik
Copy link

ermik commented Aug 4, 2018

I am not getting a server on bare init run nor does it appear with --server server.go. Maybe I am doing it wrong?

@vektah
Copy link
Collaborator

vektah commented Aug 4, 2018

Init only works in an empty directory, maybe -v tells you more?

@ermik
Copy link

ermik commented Aug 4, 2018

Aha! It works in a non-empty directory, but it only creates the yaml. Got it.

cgxxv pushed a commit to cgxxv/gqlgen that referenced this pull request Mar 25, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants