github.com/Kartograf/gqlgen@v0.7.2/example/type-system-extension/server/server.go (about)

     1  package main
     2  
     3  import (
     4  	"log"
     5  	"net/http"
     6  	"os"
     7  
     8  	"github.com/99designs/gqlgen/example/type-system-extension"
     9  	"github.com/99designs/gqlgen/handler"
    10  )
    11  
    12  const defaultPort = "8080"
    13  
    14  func main() {
    15  	port := os.Getenv("PORT")
    16  	if port == "" {
    17  		port = defaultPort
    18  	}
    19  
    20  	http.Handle("/", handler.Playground("GraphQL playground", "/query"))
    21  	http.Handle("/query", handler.GraphQL(
    22  		type_system_extension.NewExecutableSchema(
    23  			type_system_extension.Config{
    24  				Resolvers: type_system_extension.NewRootResolver(),
    25  				Directives: type_system_extension.DirectiveRoot{
    26  					EnumLogging:   type_system_extension.EnumLogging,
    27  					FieldLogging:  type_system_extension.FieldLogging,
    28  					InputLogging:  type_system_extension.InputLogging,
    29  					ObjectLogging: type_system_extension.ObjectLogging,
    30  					ScalarLogging: type_system_extension.ScalarLogging,
    31  					UnionLogging:  type_system_extension.UnionLogging,
    32  				},
    33  			},
    34  		),
    35  	))
    36  
    37  	log.Printf("connect to http://localhost:%s/ for GraphQL playground", port)
    38  	log.Fatal(http.ListenAndServe(":"+port, nil))
    39  }