Skip to content

Instantly share code, notes, and snippets.

@vniche
Created March 7, 2020 01:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vniche/5b6666493944acd0f58e237d95df4144 to your computer and use it in GitHub Desktop.
Save vniche/5b6666493944acd0f58e237d95df4144 to your computer and use it in GitHub Desktop.
Intial main.go to use with gqlgen
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