github.com/vetcher/gqlgen@v0.6.0/codegen/templates/server.gotpl (about) 1 package main 2 3 import ( 4 {{- range $import := .Imports }} 5 {{- $import.Write }} 6 {{ end }} 7 ) 8 9 const defaultPort = "8080" 10 11 func main() { 12 port := os.Getenv("PORT") 13 if port == "" { 14 port = defaultPort 15 } 16 17 http.Handle("/", handler.Playground("GraphQL playground", "/query")) 18 http.Handle("/query", handler.GraphQL({{.ExecPackageName}}.NewExecutableSchema({{.ExecPackageName}}.Config{Resolvers: &{{.ResolverPackageName}}.Resolver{}}))) 19 20 log.Printf("connect to http://localhost:%s/ for GraphQL playground", port) 21 log.Fatal(http.ListenAndServe(":" + port, nil)) 22 }