29 lines
651 B
Go
29 lines
651 B
Go
package server
|
|
|
|
import (
|
|
"log"
|
|
"net/http"
|
|
"os"
|
|
|
|
"github.com/99designs/gqlgen/graphql/handler"
|
|
"github.com/99designs/gqlgen/graphql/playground"
|
|
"somepi.ddns.net/gitea/gilex-dev/YetAnotherToDoList/graph"
|
|
)
|
|
|
|
const defaultPort = "8080"
|
|
|
|
func main() {
|
|
port := os.Getenv("PORT")
|
|
if port == "" {
|
|
port = defaultPort
|
|
}
|
|
|
|
srv := handler.NewDefaultServer(graph.NewExecutableSchema(graph.Config{Resolvers: &graph.Resolver{}}))
|
|
|
|
http.Handle("/", playground.Handler("GraphQL playground", "/query"))
|
|
http.Handle("/query", srv)
|
|
|
|
log.Printf("connect to http://localhost:%s/ for GraphQL playground", port)
|
|
log.Fatal(http.ListenAndServe(":"+port, nil))
|
|
}
|