aboutsummaryrefslogblamecommitdiffstats
path: root/vendor/github.com/99designs/gqlgen/codegen/templates/server.gotpl
blob: 38dc0d18225c69c69b5040415b57685186151f9e (plain) (tree)
1
2
3
4
5
6
7
8
9
10


            






                                                                 










                                                                            
                                                                                                                                                                                                                 



                                                                                  
package main

import (
	%%%IMPORTS%%%

	{{ reserveImport "context" }}
	{{ reserveImport "log" }}
	{{ reserveImport "net/http" }}
	{{ reserveImport "os" }}
	{{ reserveImport "github.com/99designs/gqlgen/handler" }}
)

const defaultPort = "8080"

func main() {
	port := os.Getenv("PORT")
	if port == "" {
		port = defaultPort
	}

	http.Handle("/", handler.Playground("GraphQL playground", "/query"))
	http.Handle("/query", handler.GraphQL({{ lookupImport .ExecPackageName }}.NewExecutableSchema({{ lookupImport .ExecPackageName}}.Config{Resolvers: &{{ lookupImport .ResolverPackageName}}.Resolver{}})))

	log.Printf("connect to http://localhost:%s/ for GraphQL playground", port)
	log.Fatal(http.ListenAndServe(":" + port, nil))
}