mirror of
https://github.com/dstotijn/hetty.git
synced 2025-07-01 18:47:29 -04:00
22 lines
502 B
Go
22 lines
502 B
Go
package api
|
|
|
|
import (
|
|
"net/http"
|
|
|
|
"github.com/99designs/gqlgen/graphql/handler"
|
|
"github.com/99designs/gqlgen/graphql/playground"
|
|
"github.com/gorilla/mux"
|
|
)
|
|
|
|
func HTTPHandler(resolver *Resolver, gqlEndpoint string) http.Handler {
|
|
router := mux.NewRouter().SkipClean(true)
|
|
router.Methods("POST").Handler(
|
|
handler.NewDefaultServer(NewExecutableSchema(Config{
|
|
Resolvers: resolver,
|
|
})),
|
|
)
|
|
router.Methods("GET").Handler(playground.Handler("GraphQL Playground", gqlEndpoint))
|
|
|
|
return router
|
|
}
|