some cleanup and gqlgen setup

This commit is contained in:
2024-11-01 19:55:30 +05:30
parent e41d27cf97
commit 1fb2d7d154
39 changed files with 5619 additions and 144 deletions

34
graph/server/main.go Normal file
View File

@@ -0,0 +1,34 @@
package main
import (
"net/http"
"os"
"gitserver.in/patialtech/mux"
"gitserver.in/patialtech/rano/graph"
"gitserver.in/patialtech/rano/pkg/logger"
)
func main() {
r := mux.NewRouter()
// graphiql
r.Get("/graphiql", graph.GraphiQL("/query"))
// graph query
r.Post("/query", graph.Query)
// catch all
r.Get("/", func(w http.ResponseWriter, r *http.Request) {
w.Write([]byte("hello there"))
})
port := os.Getenv("GRAPH_PORT")
if port == "" {
port = "4001"
}
r.Serve(func(srv *http.Server) error {
srv.Addr = ":" + port
logger.Info("graph server listening on %s", srv.Addr)
return srv.ListenAndServe()
})
}