1package main
2
3import (
4{{- range $import := .Imports }}
5 {{- $import.Write }}
6{{ end }}
7)
8
9const defaultPort = "8080"
10
11func 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}