Initial commit

This commit is contained in:
Kevin Kandlbinder 2023-02-24 22:17:45 +01:00
commit 15407746e3
37 changed files with 8525 additions and 0 deletions

28
internal/server/server.go Normal file
View file

@ -0,0 +1,28 @@
package server
import (
"github.com/99designs/gqlgen/graphql/handler"
"github.com/99designs/gqlgen/graphql/playground"
"github.com/Unkn0wnCat/calapi/graph"
"log"
"net/http"
"os"
)
const defaultPort = "8080"
func Serve() {
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))
}