You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
29 lines
634 B
Go
29 lines
634 B
Go
1 year ago
|
package main
|
||
|
|
||
|
import (
|
||
|
"log"
|
||
|
"net/http"
|
||
|
"os"
|
||
|
|
||
|
"github.com/99designs/gqlgen/graphql/handler"
|
||
|
"github.com/99designs/gqlgen/graphql/playground"
|
||
|
"github.com/Dan6erbond/sitling/users/graph"
|
||
|
)
|
||
|
|
||
|
const defaultPort = "3006"
|
||
|
|
||
|
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))
|
||
|
}
|