taskcafe/api/graph/graph.go

23 lines
528 B
Go
Raw Normal View History

2020-04-10 04:40:22 +02:00
package graph
import (
"net/http"
"github.com/99designs/gqlgen/handler"
"github.com/jordanknott/project-citadel/api/pg"
)
// NewHandler returns a new graphql endpoint handler.
func NewHandler(repo pg.Repository) http.Handler {
return handler.GraphQL(NewExecutableSchema(Config{
Resolvers: &Resolver{
Repository: repo,
},
}))
}
// NewPlaygroundHandler returns a new GraphQL Playground handler.
func NewPlaygroundHandler(endpoint string) http.Handler {
return handler.Playground("GraphQL Playground", endpoint)
}