server

command
v0.0.0-...-943f397 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 14, 2019 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

package main

import (

"log"
"net/http"
"os"

"github.com/99designs/gqlgen/handler"
hackernews_gqlgen_server "github.com/abodhare/hackernews-gqlgen-server"

)

const defaultPort = "4000"

func main() {
	port := os.Getenv("PORT")
	if port == "" {
		port = defaultPort
	}

	http.Handle("/playground", handler.Playground("GraphQL playground", "/"))
	http.Handle("/", handler.GraphQL(hackernews_gqlgen_server.NewExecutableSchema(hackernews_gqlgen_server.Config{Resolvers: &hackernews_gqlgen_server.Resolver{}})))

	log.Printf("connect to http://localhost:%s/ for GraphQL playground", port)
	log.Fatal(http.ListenAndServe(":"+port, nil))
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL