Created
March 7, 2020 01:29
-
-
Save vniche/5b6666493944acd0f58e237d95df4144 to your computer and use it in GitHub Desktop.
Intial main.go to use with gqlgen
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"log" | |
"net/http" | |
"os" | |
"github.com/99designs/gqlgen/handler" | |
"github.com/artemis-tech/sample-graph/graph" | |
) | |
func main() { | |
port := "3030" | |
if os.Getenv("PORT") != "" { | |
port = os.Getenv("PORT") | |
} | |
http.Handle("/graphql/playground", handler.Playground("GraphQL playground", "/query")) | |
http.Handle("/query", handler.GraphQL(graph.NewExecutableSchema( | |
graph.Config{Resolvers: &graph.Resolver{}}), | |
)) | |
log.Printf("connect to http://localhost:%s/graphql/playground for GraphQL playground", port) | |
log.Fatal(http.ListenAndServe(":"+port, nil)) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment