authorizer/server/handlers/graphql.go

20 lines
627 B
Go
Raw Permalink Normal View History

package handlers
import (
"github.com/99designs/gqlgen/graphql/handler"
2022-09-30 10:07:59 +00:00
graph "github.com/authorizerdev/authorizer/server/graph"
2021-07-23 16:27:44 +00:00
"github.com/authorizerdev/authorizer/server/graph/generated"
"github.com/gin-gonic/gin"
)
2022-01-17 06:02:13 +00:00
// GraphqlHandler is the main handler that handels all the graphql requests
func GraphqlHandler() gin.HandlerFunc {
// NewExecutableSchema and Config are in the generated.go file
// Resolver is in the resolver.go file
h := handler.NewDefaultServer(generated.NewExecutableSchema(generated.Config{Resolvers: &graph.Resolver{}}))
return func(c *gin.Context) {
h.ServeHTTP(c.Writer, c.Request)
}
}