authorizer/server/handlers/graphql.go

20 lines
621 B
Go
Raw Normal View History

package handlers
import (
"github.com/99designs/gqlgen/graphql/handler"
2023-03-26 02:18:06 +00:00
"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)
}
}